﻿<ResourceDictionary x:Class="DarkBlue.Core"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:system="clr-namespace:System;assembly=mscorlib">
    
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Brushes.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <!-- Button -->
    <Style TargetType="{x:Type Button}">
        <Setter Property="TextOptions.TextHintingMode" Value="Animated" />
        <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
        <Setter Property="Background" Value="{StaticResource ControlBackgroundNormal}"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusLine}"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid x:Name="Root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.4" />
                                    <VisualTransition To="Pressed" />
                                    <VisualTransition From="Pressed" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PressedElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="NormalElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0.25" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="PressedElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0" />
                                        <ColorAnimation Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="ContentHost" To="#32ebfb"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="NormalElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="ContentHost" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0.75" />
                                        <ColorAnimation Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="ContentHost" To="{StaticResource DisabledForeground}"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused"/>
                                <VisualState x:Name="Unfocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="DisabledElement" Background="{StaticResource DisabledBrush}" CornerRadius="2" Opacity="0">
                            <Border BorderBrush="{StaticResource DisabledBorderBrush}" BorderThickness="0,0,1,1" CornerRadius="2" />
                        </Border>
                        <Border x:Name="NormalElement" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="2"
                                BorderThickness="{TemplateBinding BorderThickness}">
                        </Border>
                        <Border x:Name="MouseOverElement" BorderBrush="{StaticResource ControlActiveBorderBrush}" Background="{StaticResource ControlBackgroundOver}" CornerRadius="2" Opacity="0" 
                                BorderThickness="{TemplateBinding BorderThickness}"/>
                        <Border x:Name="PressedElement" Background="{StaticResource ControlBackgroundPressed}" CornerRadius="2" Opacity="0" BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{StaticResource ControlActiveBorderBrush}"/>
                        <ContentPresenter x:Name="ContentHost" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ToggleButton -->
    <Style TargetType="{x:Type ToggleButton}">
        <Setter Property="TextOptions.TextHintingMode" Value="Animated" />
        <Setter Property="Foreground" Value="{StaticResource ControlForeground}" />
        <Setter Property="Background" Value="{StaticResource ControlBackgroundNormal}"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusLine}"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid x:Name="Root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.4" />
                                    <VisualTransition To="Pressed" />
                                    <VisualTransition From="Pressed"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="NormalElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="HighlightElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0.5" />
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="ContentHost" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0.75" />
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="CheckedElement" />
                                        <ColorAnimation Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="ContentHost" To="{StaticResource DisabledForeground}"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CheckStates">
                                <VisualState x:Name="Checked">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="NormalElement" />
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="HighlightElement" />
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="CheckedElement" />
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="MouseOverElement">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unchecked" />
                                <VisualState x:Name="Indeterminate" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="DisabledElement" Background="{StaticResource DisabledBrush}" CornerRadius="2" Opacity="0">
                            <Border BorderBrush="{StaticResource DisabledBorderBrush}" BorderThickness="0,0,1,1" CornerRadius="2" />
                        </Border>
                        <Border x:Name="NormalElement" Background="{StaticResource ControlBackgroundNormal}" CornerRadius="2" Effect="{StaticResource ControlShadowEffect}" />
                        <Border x:Name="CheckedElement" CornerRadius="2.5" BorderBrush="#D0494a4d" BorderThickness="1" Margin="0,-1,0,-1" Opacity="0"
                                Background="{StaticResource ControlBackgroundLine}">
                            <Border BorderBrush="#70303030" BorderThickness="1,1,0,0" CornerRadius="2">
                                <Border BorderBrush="#30303030" BorderThickness="1" CornerRadius="1.5">
                                    <Border BorderBrush="#10303030" BorderThickness="1,1,0,0" CornerRadius="1" />
                                </Border>
                            </Border>
                        </Border>
                        <Border x:Name="MouseOverElement" Background="{StaticResource ToggleButtonHoverBrush}" BorderBrush="{StaticResource ControlActiveBorderBrush}" 
                                CornerRadius="2" Opacity="0" BorderThickness="{TemplateBinding BorderThickness}"/>
                        <Border x:Name="HighlightElement" BorderBrush="{StaticResource ControlHighlight}" BorderThickness="{StaticResource BorderThicknessButtonOutline}" CornerRadius="2" />
                        <ContentPresenter x:Name="ContentHost" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                            <ContentPresenter.Effect>
                                <DropShadowEffect Color="{StaticResource ColorForegroundShadowColor}" Direction="-90" BlurRadius="1" ShadowDepth="1" Opacity="0.5" />
                            </ContentPresenter.Effect>
                        </ContentPresenter>
                        <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="False" Margin="0" Opacity="0" RadiusX="1" RadiusY="1" Stroke="{StaticResource FocusVisualBrush}" StrokeThickness="1" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    
    <!-- CheckBox -->
    <Style TargetType="{x:Type CheckBox}">
        <Setter Property="Background" Value="{StaticResource ControlBackgroundNormal}" />
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}" />
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="Padding" Value="4,0" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusLine_Occupado}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Storyboard.TargetProperty="(Rectangle.Stroke).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="background_checkbox"
                                            Duration="0:0:0.3" To="{StaticResource BorderBrushGradientColor1}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Rectangle.Stroke).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="background_checkbox"
                                            Duration="0:0:0.3" To="{StaticResource BorderBrushGradientColor2}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Storyboard.TargetProperty="(Rectangle.Stroke).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="background_checkbox"
                                            Duration="0:0:0.3" To="{StaticResource BorderBrushSolidColor}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Rectangle.Stroke).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="background_checkbox"
                                            Duration="0:0:0.3" To="{StaticResource BorderBrushSolidColor}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <BulletDecorator Background="Transparent">
                        <BulletDecorator.Bullet>
                            <Grid Width="16" Height="16">
                                <Rectangle Height="14" Width="14" x:Name="background_checkbox" Stroke="{TemplateBinding BorderBrush}"
                                           Fill="{TemplateBinding Background}"/>
                                <Path x:Name="check_icon" Opacity="0" Stretch="Fill" 
                                      Data="M102.03442,598.79645 L105.22962,597.78918 L106.95686,599.19977 C106.95686,599.19977 113.77958,590.53656 113.77958,590.53656 C113.77958,590.53656 107.40649,603.79431 107.40649,603.79431 z" 
                                      Fill="{StaticResource ControlActiveBorderBrush}" Height="10" Width="11"/>
                                <Rectangle Height="7" Width="7" x:Name="background_null_checkbox" Fill="{StaticResource ControlActiveBorderBrush}" Opacity="0"/>
                                <Rectangle Height="12" Width="12" x:Name="background_disabled_checkbox" Fill="{StaticResource DisabledBrush}" 
                                           Stroke="{StaticResource DisabledBorderBrush}" StrokeThickness="1" Opacity="0"/>
                            </Grid>
                        </BulletDecorator.Bullet>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" 
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                    </BulletDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="check_icon" Property="Opacity" Value="1"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="{x:Null}">
                            <Setter TargetName="background_null_checkbox" Property="Opacity" Value="1"/>
                            <Setter Property="Opacity" Value="0.9"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="background_disabled_checkbox" Property="Opacity" Value="1"/>
                            <Setter Property="Opacity" Value="0.72"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- RadioButton -->
    <Style TargetType="{x:Type RadioButton}">
        <Setter Property="Background" Value="{StaticResource ControlBackgroundNormal}" />
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}" />
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusLine_Occupado}"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="Padding" Value="4 0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RadioButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Storyboard.TargetProperty="(Rectangle.Stroke).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="background_radiobutton"
                                            Duration="0:0:0.3" To="{StaticResource BorderBrushGradientColor1}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Rectangle.Stroke).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="background_radiobutton"
                                            Duration="0:0:0.3" To="{StaticResource BorderBrushGradientColor2}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Storyboard.TargetProperty="(Rectangle.Stroke).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="background_radiobutton"
                                            Duration="0:0:0.3" To="{StaticResource BorderBrushSolidColor}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Rectangle.Stroke).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="background_radiobutton"
                                            Duration="0:0:0.3" To="{StaticResource BorderBrushSolidColor}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <BulletDecorator Background="Transparent">
                        <BulletDecorator.Bullet>
                            <Grid Width="16" Height="16">
                                <Ellipse Height="14" Margin="1" x:Name="background_radiobutton" Width="14" Fill="{TemplateBinding Background}"
                                         Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1"/>
                                <Ellipse Height="6" Width="6" x:Name="bullet_checked_radiobutton" Fill="{StaticResource ControlActiveBorderBrush}" Opacity="0"
                                         Stroke="Transparent" StrokeThickness="1"/>
                                <Ellipse Height="12" Width="12" x:Name="bullet_disabled_radiobutton" Opacity="0"
                                         Fill="{StaticResource DisabledBrush}" Stroke="{StaticResource DisabledBorderBrush}" StrokeThickness="1"/>
                            </Grid>
                        </BulletDecorator.Bullet>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" 
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                    </BulletDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="bullet_checked_radiobutton" Property="Opacity" Value="1"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="{x:Null}">
                            <Setter TargetName="bullet_checked_radiobutton" Property="Opacity" Value="1"/>
                            <Setter TargetName="bullet_checked_radiobutton" Property="Fill" Value="Transparent"/>
                            <Setter TargetName="bullet_checked_radiobutton" Property="Stroke" Value="{StaticResource ControlActiveBorderBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="bullet_disabled_radiobutton" Property="Opacity" Value="1"/>
                            <Setter Property="Opacity" Value="0.72"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- TextBox -->
    <Style TargetType="{x:Type TextBox}" BasedOn="{x:Null}">
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}" />
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}" />
        <Setter Property="CaretBrush" Value="{StaticResource ControlActiveBorderBrush}"/>
        <Setter Property="AllowDrop" Value="True"/>
        <Setter Property="Height" Value="34"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="5"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Duration="0:0:0.4" Storyboard.TargetName="txb_mouseOver1" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                            <DoubleAnimation Duration="0:0:0" Storyboard.TargetName="txb_mouseOver2" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                            <ColorAnimation Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0" To="Transparent"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0" To="Transparent"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Duration="0:0:0.4" Storyboard.TargetName="txb_mouseOver1" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0" />
                            <DoubleAnimation Duration="0:0:0" Storyboard.TargetName="txb_mouseOver2" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0" BeginTime="0:0:0.4" />
                            <ColorAnimation Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0" To="{StaticResource BorderLightBrushGradientColor1}" BeginTime="0:0:0.4"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0" To="{StaticResource BorderLightBrushGradientColor2}" BeginTime="0:0:0.4"/>
                        </Storyboard>
                        <Storyboard x:Key="FocusOn">
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor1}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor2}"/>
                        </Storyboard>
                        <Storyboard x:Key="FocusOff">
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushSolidColor}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushSolidColor}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Border x:Name="txb_mouseOver2" Background="{TemplateBinding Background}" Opacity="0" CornerRadius="4" />
                        <Border x:Name="txb_mouseOver1" Background="{StaticResource ControlBackgroundLine}" Opacity="0" CornerRadius="4" />
                        <Border x:Name="txb_border" Background="{TemplateBinding Background}" CornerRadius="4" 
                            BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                            <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" TargetName="txb_border" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            <Setter Property="Opacity" Value="0.85"/>
                            <Setter TargetName="txb_border" Property="BorderBrush" Value="{StaticResource DisabledBrush}"/>
                            <Setter TargetName="txb_border" Property="BorderThickness" Value="1"/>
                        </Trigger>
                        <Trigger Property="IsKeyboardFocused" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource FocusOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource FocusOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- PasswordBox -->
    <Style TargetType="{x:Type PasswordBox}" BasedOn="{x:Null}">
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}" />
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Foreground" Value="{StaticResource ControlForeground}" />
        <Setter Property="CaretBrush" Value="{StaticResource ControlActiveBorderBrush}"/>
        <Setter Property="AllowDrop" Value="True"/>
        <Setter Property="Height" Value="34"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="5"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type PasswordBox}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Duration="0:0:0.4" Storyboard.TargetName="txb_mouseOver1" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                            <DoubleAnimation Duration="0:0:0" Storyboard.TargetName="txb_mouseOver2" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                            <ColorAnimation Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0" To="Transparent"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0" To="Transparent"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Duration="0:0:0.4" Storyboard.TargetName="txb_mouseOver1" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0" />
                            <DoubleAnimation Duration="0:0:0" Storyboard.TargetName="txb_mouseOver2" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0" BeginTime="0:0:0.4"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0" To="{StaticResource BorderLightBrushGradientColor1}" BeginTime="0:0:0.4"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0" To="{StaticResource BorderLightBrushGradientColor2}" BeginTime="0:0:0.4"/>
                        </Storyboard>
                        <Storyboard x:Key="FocusOn">
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor1}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor2}"/>
                        </Storyboard>
                        <Storyboard x:Key="FocusOff">
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushSolidColor}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushSolidColor}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Border x:Name="txb_mouseOver2" Background="{TemplateBinding Background}" Opacity="0" CornerRadius="2" />
                        <Border x:Name="txb_mouseOver1" Background="{StaticResource ControlBackgroundLine}" Opacity="0" CornerRadius="2" />
                        <Border x:Name="txb_border" Background="{TemplateBinding Background}" CornerRadius="2" 
                            BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                            <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" TargetName="txb_border" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            <Setter Property="Opacity" Value="0.85"/>
                            <Setter TargetName="txb_border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}"/>
                        </Trigger>
                        <Trigger Property="IsKeyboardFocused" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource FocusOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource FocusOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- RichTextBox -->
    <Style TargetType="{x:Type RichTextBox}" BasedOn="{x:Null}">
        <Style.Resources>
            <Style x:Key="{x:Type FlowDocument}" TargetType="{x:Type FlowDocument}">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
            </Style>
        </Style.Resources>
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}" />
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}" />
        <Setter Property="CaretBrush" Value="{StaticResource ControlActiveBorderBrush}"/>
        <Setter Property="AllowDrop" Value="True"/>
        <Setter Property="Height" Value="34"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="5"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RichTextBox}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="FocusOn">
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor1}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor2}"/>
                        </Storyboard>
                        <Storyboard x:Key="FocusOff">
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushSolidColor}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="txb_border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushSolidColor}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Border x:Name="txb_mouseOver2" Background="{TemplateBinding Background}" Opacity="0" CornerRadius="2" />
                        <Border x:Name="txb_mouseOver1" Background="{StaticResource ControlBackgroundLine}" Opacity="0" CornerRadius="2" />
                        <Border x:Name="txb_border" Background="{TemplateBinding Background}" CornerRadius="2" 
                            BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                            <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" TargetName="txb_border" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            <Setter Property="Opacity" Value="0.85"/>
                            <Setter TargetName="txb_border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}"/>
                        </Trigger>
                        <Trigger Property="IsKeyboardFocused" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource FocusOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource FocusOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- ScrollBar -->
    <Style TargetType="{x:Type ScrollBar}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollBar}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                       <Grid x:Name="GridScrollBar" Width="16" Background="{TemplateBinding Background}">
                           <Grid.RowDefinitions>
                               <RowDefinition MaxHeight="16"/>
                               <RowDefinition/>
                               <RowDefinition MaxHeight="16"/>
                           </Grid.RowDefinitions>
                           <RepeatButton x:Name="PageUpButton" Grid.Row="0" Command="ScrollBar.LineUpCommand" Style="{DynamicResource RepeatButtonArrowScrollBar}"/>
                           <Track x:Name="PART_Track" Grid.Row="1" Orientation="Vertical" IsDirectionReversed="True">
                               <Track.Thumb>
                                   <Thumb Style="{DynamicResource ThumbScrollBar}"/>
                               </Track.Thumb>
                               <Track.DecreaseRepeatButton>
                                   <RepeatButton x:Name="DecreaseRepeatButton" Command="ScrollBar.PageUpCommand" Style="{DynamicResource RepeatButtonPageScrollBar}"/>
                               </Track.DecreaseRepeatButton>
                               <Track.IncreaseRepeatButton>
                                   <RepeatButton x:Name="IncreaseRepeatButton" Command="ScrollBar.PageDownCommand" Style="{DynamicResource RepeatButtonPageScrollBar}"/>
                               </Track.IncreaseRepeatButton>
                           </Track>
                           <RepeatButton x:Name="PageDownButton" Grid.Row="2" Command="ScrollBar.LineDownCommand" Style="{DynamicResource RepeatButtonArrowScrollBar}">
                               <RepeatButton.LayoutTransform>
                                   <RotateTransform Angle="180"/>
                               </RepeatButton.LayoutTransform>
                           </RepeatButton>
                       </Grid>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="Orientation" Value="Horizontal">
                            <Setter Property="LayoutTransform" TargetName="GridScrollBar">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="PART_Track" Property="Orientation" Value="Vertical"/>
                            <Setter Property="Command" Value="ScrollBar.LineRightCommand" TargetName="IncreaseRepeatButton"/>
                            <Setter Property="Command" Value="ScrollBar.LineLeftCommand" TargetName="DecreaseRepeatButton"/>
                            <Setter Property="Command" Value="ScrollBar.PageRightCommand" TargetName="PageDownButton"/>
                            <Setter Property="Command" Value="ScrollBar.PageLeftCommand" TargetName="PageUpButton"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RepeatButtonArrowScrollBar" TargetType="{x:Type RepeatButton}" BasedOn="{x:Null}">
        <Setter Property="Height" Value="16"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <ControlTemplate.Resources>
                        
                        <Geometry x:Key="path">F1 M 23.9063,22.5L 21.9063,24.5L 14.9063,31.75L 14.9063,25.25L 23.9063,15.75L 32.9063,25.25L 32.9063,31.75L 25.9063,24.5L 23.9063,22.5 Z</Geometry>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Border x:Name="brd" Background="Transparent"/>
                        <Path x:Name="RepeatButtonArrow" Fill="{StaticResource NormalBrushScrollBar}" 
                              Data="{StaticResource path}"
                              StrokeStartLineCap="Round" StrokeEndLineCap="Round" Stretch="Fill" UseLayoutRounding="False"
                              HorizontalAlignment="Center" VerticalAlignment="Center" Height="8" Width="8"/>
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" 
                                          Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="RepeatButtonArrow" Property="Fill" Value="{StaticResource HoverBrushScrollBar}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="RepeatButtonArrow" Property="Fill" Value="#FFF"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="RepeatButtonArrow" Property="Fill" Value="{StaticResource DisabledBrushScrollBar}"/>
                            <Setter TargetName="RepeatButtonArrow" Property="Opacity" Value="0.72"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ThumbScrollBar" TargetType="{x:Type Thumb}">
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Duration="0:0:0.3" Storyboard.TargetName="hoverRect_thumb" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Duration="0:0:0.3" Storyboard.TargetName="hoverRect_thumb" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0" />
                        </Storyboard>
                        <Storyboard x:Key="PressedOn">
                            <DoubleAnimation Duration="0:0:0.3" Storyboard.TargetName="pressedRect_thumb" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="1" />
                        </Storyboard>
                        <Storyboard x:Key="PressedOff">
                            <DoubleAnimation Duration="0:0:0.3" Storyboard.TargetName="pressedRect_thumb" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To="0" />
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Rectangle x:Name="rect_thumb" RadiusX="4" RadiusY="4" Fill="{StaticResource NormalBrushScrollBar}" Width="8"/>
                        <Rectangle x:Name="hoverRect_thumb" RadiusX="3" RadiusY="3" Fill="{StaticResource ScrollBarThumbBackground}" Width="6" Margin="1,2" Opacity="0" />
                        <Rectangle x:Name="pressedRect_thumb" Fill="{StaticResource ScrollBarThumbPressedBackground}" RadiusX="4" RadiusY="4" Width="8" Margin="1,2" Opacity="0" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter TargetName="rect_thumb" Property="Fill" Value="{StaticResource ScrollBarThumbPressedBackground}"/>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource PressedOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource PressedOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="rect_thumb" Property="Fill" Value="{StaticResource DisabledBrushScrollBar}"/>
                            <Setter TargetName="rect_thumb" Property="Opacity" Value="0.72"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RepeatButtonPageScrollBar" TargetType="{x:Type RepeatButton}">
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="Transparent"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    
    <!-- ScrollViewer -->
    <Style TargetType="{x:Type ScrollViewer}" BasedOn="{x:Null}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <ScrollContentPresenter Grid.Column="0" Grid.Row="0" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" 
                                                ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}"/>
                        <ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Grid.Column="0" Grid.Row="1" 
                                   x:Name="PART_HorizontalScrollBar" Orientation="Horizontal" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                   ViewportSize="{TemplateBinding ViewportWidth}" Minimum="0" Maximum="{TemplateBinding ScrollableWidth}" AutomationProperties.AutomationId="HorizontalScrollBar"/>
                        <ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Grid.Column="1" Grid.Row="0" 
                                   x:Name="PART_VerticalScrollBar" Orientation="Vertical" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                   ViewportSize="{TemplateBinding ViewportHeight}" Minimum="0" Maximum="{TemplateBinding ScrollableHeight}" AutomationProperties.AutomationId="VerticalScrollBar"/>
                        <Border Grid.Column="1" Grid.Row="1" Background="Transparent"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- GroupBox -->
    <Style TargetType="{x:Type GroupBox}">
        <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GroupBox}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid SnapsToDevicePixels="True">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Border x:Name="header_groupbox" Grid.Row="0" Padding="5" CornerRadius="5,5,0,0"
                                Background="{StaticResource ControlBackgroundNormal}"  BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1,1,1,0">
                                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header" RecognizesAccessKey="True"/>
                            </Border>
                            <Border Grid.Row="0" Margin="2" Background="Transparent" CornerRadius="4,4,0,0"/>
                            <Border x:Name="container_groupbox" Grid.Row="1" CornerRadius="0,0,5,5" Background="{TemplateBinding Background}" 
                                BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1,1,1,1">
                                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}"/>
                            </Border>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="header_groupbox" Property="Background" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Opacity" Value="0.5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- ComboBox -->
    <Style TargetType="{x:Type ToggleButton}" x:Key="ComboBoxToggleButton">
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="Border"
                                Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor1}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="Border"
                                Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor2}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Path.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="ArrowDown"
                                Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor2}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Path.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="ArrowDown"
                                Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor2}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Path.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="ArrowUp"
                                Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor2}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Path.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="ArrowUp"
                                Duration="0:0:0.4" To="{StaticResource BorderBrushGradientColor2}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="Border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushSolidColor}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="Border"
                                            Duration="0:0:0.4" To="{StaticResource BorderBrushSolidColor}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Path.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="ArrowDown"
                                Duration="0:0:0.4" To="{StaticResource ArrowBrushComboBox}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Path.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="ArrowDown"
                                Duration="0:0:0.4" To="{StaticResource ArrowBrushComboBox}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Path.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="ArrowUp"
                                Duration="0:0:0.4" To="{StaticResource ArrowBrushComboBox}"/>
                            <ColorAnimation Storyboard.TargetProperty="(Path.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="ArrowUp"
                                Duration="0:0:0.4" To="{StaticResource ArrowBrushComboBox}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Border Grid.ColumnSpan="2" CornerRadius="6"
                            BorderThickness="{Binding BorderThickness, Mode=OneWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ComboBox}}}" 
                            BorderBrush="{Binding BorderBrush, Mode=OneWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ComboBox}}}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="24" />
                            </Grid.ColumnDefinitions>
                            <Border x:Name="Border" Grid.ColumnSpan="2" CornerRadius="5" Background="{StaticResource ControlBackgroundNormal}" 
                                    BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" />
                            <Border x:Name="BorderToggle" Grid.Column="0" CornerRadius="3,0,0,3" 
                                    Background="{Binding Background, Mode=OneWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ComboBox}}}"
                                    BorderBrush="{StaticResource ControlBorderBrush}" Margin="1" BorderThickness="0,0,1,0" />
                            <Grid Grid.Column="1">
                                <Path x:Name="ArrowDown" HorizontalAlignment="Center" VerticalAlignment="Center"
                                      Data="M -2 0 L 2 4 L 6 0 Z" Margin="0,8,0,0">
                                    <Path.Fill>
                                        <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                                            <GradientStop Color="{StaticResource ArrowBrushComboBox}" Offset="0.204" />
                                            <GradientStop Color="{StaticResource ArrowBrushComboBox}" Offset="0.864" />
                                        </LinearGradientBrush>
                                    </Path.Fill>
                                </Path>
                                <Path x:Name="ArrowUp" HorizontalAlignment="Center" VerticalAlignment="Center"
                                      Data="M -2 4 L 2 0 L 6 4 Z" Margin="0,0,0,8">
                                    <Path.Fill>
                                        <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                                            <GradientStop Color="{StaticResource ArrowBrushComboBox}" Offset="0.204" />
                                            <GradientStop Color="{StaticResource ArrowBrushComboBox}" Offset="0.864" />
                                        </LinearGradientBrush>
                                    </Path.Fill>
                                </Path>
                            </Grid>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="ToggleButton.IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBrush}" />
                            <Setter TargetName="BorderToggle" Property="Background" Value="{StaticResource DisabledBrush}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="ArrowDown" Property="Fill">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="ArrowUp" Property="Fill">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <ControlTemplate x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">
        <Border x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}" />
    </ControlTemplate>
    <Style x:Key="{x:Type ComboBox}" TargetType="{x:Type ComboBox}">
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}"/>
        <Setter Property="Width" Value="Auto"/>
        <Setter Property="Height" Value="28"/>
        <Setter Property="FontFamily" Value="Calibri,Arial"/>
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="Padding" Value="4"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="IsSynchronizedWithCurrentItem" Value="False"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel IsVirtualizing="True"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBox}">
                    <Grid>
                        <ToggleButton Name="ToggleButton" Style="{StaticResource ComboBoxToggleButton}" Grid.Column="2" Focusable="False"
                                      IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
                        <ContentPresenter Name="ContentSite" IsHitTestVisible="False" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Margin="6,3,32,3" VerticalAlignment="Center"
                                          HorizontalAlignment="Left"  />
                        <TextBox x:Name="PART_EditableTextBox" Style="{x:Null}" Template="{StaticResource ComboBoxTextBox}" HorizontalAlignment="Left" 
                                 VerticalAlignment="Center" Margin="6,3,32,3" Focusable="True" Background="Transparent" Visibility="Hidden" IsReadOnly="{TemplateBinding IsReadOnly}"/>
                        <Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}" AllowsTransparency="True" Focusable="False"
                               PopupAnimation="Slide" Margin="3,-8,-3,8">
                            <Grid Name="DropDown" SnapsToDevicePixels="True" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
                                <Border x:Name="DropDownBorder" Background="{StaticResource ControlLightBackground}" BorderThickness="1" CornerRadius="3" Margin="0,3,0,3"
                                        BorderBrush="{StaticResource ControlBorderBrush}"/>
                                <ScrollViewer Margin="0,3" SnapsToDevicePixels="True">
                                    <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
                                </ScrollViewer>
                            </Grid>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasItems" Value="False">
                            <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Background" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Opacity" Value="0.72"/>
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="True">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
                        </Trigger>
                        <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="True"/>
                        <Trigger Property="IsEditable" Value="True">
                            <Setter Property="IsTabStop" Value="False"/>
                            <Setter TargetName="PART_EditableTextBox" Property="Visibility"	Value="Visible"/>
                            <Setter TargetName="ContentSite" Property="Visibility" Value="Hidden"/>
                        </Trigger>
                        <Trigger Property="IsDropDownOpen" Value="True">
                            <Setter Property="BorderBrush" Value="{StaticResource ControlActiveBorderBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
        </Style.Triggers>
    </Style>
    <Style x:Key="{x:Type ComboBoxItem}" TargetType="ComboBoxItem">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Storyboard.TargetName="content" Storyboard.TargetProperty="(ComboBoxItem.Foreground).(SolidColorBrush.Color)"
                                            Duration="0:0:0.3" To="{StaticResource BorderBrushGradientColor2}"/>
                            <ColorAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)"
                                            Duration="0:0:0" To="{StaticResource HighlightComboBoxItem1}"/>
                            <ColorAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                            Duration="0:0:0" To="{StaticResource HighlightComboBoxItem2}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Storyboard.TargetName="content" Storyboard.TargetProperty="(ComboBoxItem.Foreground).(SolidColorBrush.Color)"
                                            Duration="0:0:0.3" To="#FFEEEFFF"/>
                            <ColorAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)"
                                            Duration="0:0:0" To="Transparent"/>
                            <ColorAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                            Duration="0:0:0" To="Transparent"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Border Name="Border" Padding="2" BorderThickness="1" SnapsToDevicePixels="True">
                        <Border.Background>
                            <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                <GradientStop Color="Transparent" Offset="0" />
                                <GradientStop Color="Transparent" Offset="1" />
                            </LinearGradientBrush>
                        </Border.Background>
                        <ContentPresenter x:Name="content"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHighlighted" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource DisabledForeground2}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- ProgressBar -->
    <Style TargetType="{x:Type ProgressBar}">
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}"/>
        <Setter Property="Maximum" Value="100"/>
        <Setter Property="Height" Value="20"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ProgressBar}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="IndeterminateProgressBar" RepeatBehavior="Forever">
                            <ObjectAnimationUsingKeyFrames Duration="00:00:00" Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="IndeterminateRoot">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Duration="00:00:00" Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="DeterminateRoot">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(LinearGradientBrush.Transform).(TransformGroup.Children)[0].X" Storyboard.TargetName="IndeterminateGradientFill">
                                <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:.35" Value="20"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid x:Name="Root">
                        <Border x:Name="PART_Track" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
                        <Grid x:Name="ProgressBarRootGrid">
                            <Grid x:Name="IndeterminateRoot" Visibility="Collapsed">
                                <Rectangle x:Name="IndeterminateSolidFill" Margin="{TemplateBinding BorderThickness}" Opacity="1" RenderTransformOrigin="0.5,0.5" StrokeThickness="0" Fill="{StaticResource BrushTrackProgressBar}"/>
                                <Rectangle x:Name="IndeterminateGradientFill" Margin="{TemplateBinding BorderThickness}" Opacity="0.7" StrokeThickness="1" Fill="{StaticResource IndeterminateBrushProgressbar}"/>
                            </Grid>
                            <Grid x:Name="DeterminateRoot" Margin="1">
                                <Border x:Name="PART_Indicator" Background="{StaticResource BrushTrackProgressBar}" HorizontalAlignment="Left" Margin="-1">
                                    <Rectangle x:Name="GradientFill" Opacity="0.7" Visibility="Collapsed" Fill="{StaticResource IndeterminateBrushProgressbar}"/>
                                </Border>
                            </Grid>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Orientation" Value="Vertical">
                            <Setter Property="LayoutTransform" TargetName="Root">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsIndeterminate" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource IndeterminateProgressBar}"/>
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Visibility" TargetName="DeterminateRoot" Value="Collapsed"/>
                            <Setter Property="Opacity" Value=".4" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="BorderThickness" Value="1"/>
    </Style>
    
    
    <!-- ToolTip -->
    <Style TargetType="{x:Type ToolTip}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="HasDropShadow" Value="True"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
        <Setter Property="FontStyle" Value="Italic"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToolTip}">
                    <Border Name="border_tooltip" Background="{StaticResource BackgroundToolTip}" BorderBrush="{StaticResource BorderBrushToolTip}" 
                            BorderThickness="2" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
                        <ContentPresenter Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasDropShadow" Value="True">
                            <Setter TargetName="border_tooltip" Property="CornerRadius" Value="5"/>
                            <Setter TargetName="border_tooltip" Property="SnapsToDevicePixels" Value="True"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="border_tooltip" Property="Background" Value="{StaticResource BackgroundToolTipDisabled}"/>
                            <Setter Property="Opacity" Value="0.82"/>
                            <Setter Property="Foreground" Value="#888"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- ResizeGrip -->
    <Style x:Key="{x:Type ResizeGrip}" TargetType="{x:Type ResizeGrip}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ResizeGrip}">
                    <Grid Background="Transparent" SnapsToDevicePixels="True">
                        <Path Data="M9,0L11,0 11,11 0,11 0,9 3,9 3,6 6,6 6,3 9,3z" Margin="0,0,2,2" HorizontalAlignment="Right" VerticalAlignment="Bottom">
                            <Path.Fill>
                                <DrawingBrush ViewportUnits="Absolute" ViewboxUnits="Absolute" Viewport="0,0,3,3" Viewbox="0,0,3,3" TileMode="Tile">
                                    <DrawingBrush.Drawing>
                                        <DrawingGroup>
                                            <DrawingGroup.Children>
                                                <GeometryDrawing Geometry="M0,0L2,0 2,2 0,2z" Brush="{StaticResource ControlActiveBorderBrush}"/>
                                            </DrawingGroup.Children>
                                        </DrawingGroup>
                                    </DrawingBrush.Drawing>
                                </DrawingBrush>
                            </Path.Fill>
                        </Path>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- TabControl -->
    <Style TargetType="{x:Type TabControl}">
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Padding" Value="4"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Background" Value="{StaticResource NormalBackgroundTabControl}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid ClipToBounds="True" SnapsToDevicePixels="True" KeyboardNavigation.TabNavigation="Local">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0"/>
                            <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
                            <RowDefinition x:Name="RowDefinition1" Height="*"/>
                        </Grid.RowDefinitions>
                        <TabPanel Margin="4,1,10,0" x:Name="HeaderPanel" Grid.Column="0" Grid.Row="0" IsItemsHost="True" Panel.ZIndex="1" KeyboardNavigation.TabIndex="1"/>
                        <Border x:Name="ContentPanel" Grid.Column="0" Grid.Row="1" BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" CornerRadius="0,5,5,5">
                            <Border x:Name="InnerBd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" 
                                    KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local" CornerRadius="0,4,4,4">
                                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" x:Name="PART_SelectedContentHost" ContentSource="SelectedContent"/>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="BorderBrush" TargetName="ContentPanel" Value="{StaticResource DisabledBorderBrush}"/>
                            <Setter Property="Background" TargetName="InnerBd" Value="{StaticResource DisabledBrush}"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="1"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,2"/>
                            <Setter Property="CornerRadius" TargetName="ContentPanel" Value="5,5,5,0"/>
                            <Setter Property="CornerRadius" TargetName="InnerBd" Value="4,4,4,0"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,2,2"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1"/>
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,2,2"/>
                            <Setter Property="CornerRadius" TargetName="ContentPanel" Value="5,0,5,5"/>
                            <Setter Property="CornerRadius" TargetName="InnerBd" Value="4,0,4,4"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type TabItem}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusLine}"/>
        <Setter Property="Background" Value="{StaticResource TabControlItemBackgroundNormal}"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Padding" Value="10"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="BorderThickness" Value="1,1,1,0" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="MinWidth" Value="10" />
        <Setter Property="MinHeight" Value="26" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            To="{StaticResource ColorForeground}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            To="{StaticResource ColorForegroundWhite}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                        <Grid SnapsToDevicePixels="True" x:Name="grid" Background="Transparent" Margin="0,0,3,0">
                            <Border x:Name="border_inner" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Padding="{TemplateBinding Padding}" 
                                    Background="{TemplateBinding Background}">
                                <ContentPresenter x:Name="Content" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                              HorizontalAlignment="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" 
                                              VerticalAlignment="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" 
                                              ContentSource="Header" RecognizesAccessKey="True"/>
                            </Border>
                            <Border x:Name="border_hover" Background="{StaticResource ControlBackgroundLine}" Opacity="0"/>
                        </Grid>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True"/>
                                <Condition Property="IsSelected" Value="False"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Background" TargetName="border_inner" Value="{StaticResource PressedBackgroundTabItem}"/>
                            <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" TargetName="border_inner" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="BorderBrush" TargetName="border_inner" Value="{StaticResource DisabledBorderBrush}"/>
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Margin" Value="2,0,-2,0"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="90"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter Property="BorderThickness" TargetName="border_inner" Value="1,0,1,1"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True"/>
                                <Condition Property="TabStripPlacement" Value="Top"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Margin" Value="-2,-2,-2,-1"/>
                            <Setter Property="Margin" TargetName="Content" Value="0,0,0,1"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True"/>
                                <Condition Property="TabStripPlacement" Value="Bottom"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Margin" Value="-2,-1,-2,-2"/>
                            <Setter Property="Margin" TargetName="Content" Value="0,1,0,0"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True"/>
                                <Condition Property="TabStripPlacement" Value="Left"/>
                            </MultiTrigger.Conditions>

                            <Setter Property="Margin" Value="-2,-2,-1,-2"/>
                            <Setter Property="Margin" TargetName="Content" Value="0,0,1,0"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True"/>
                                <Condition Property="TabStripPlacement" Value="Right"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Margin" Value="-1,-2,-2,-2"/>
                            <Setter Property="Margin" TargetName="Content" Value="1,0,0,0"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- Menu -->
    <Geometry x:Key="CheckMarker">M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z</Geometry>
    <Geometry x:Key="RightArrow">M 0,0 L 4,3.5 L 0,7 Z</Geometry>

    <Style TargetType="{x:Type Menu}">
        <Setter Property="Background" Value="{StaticResource ControlBackgroundNormal}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="BorderThickness" Value="0,0,0,1"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Menu}">
                    <Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Opacity" Value="0.78"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type MenuItem}">
        <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Padding" Value="7,2,8,3"/>
                <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Padding" Value="7,2,8,3"/>
                <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=TopLevelItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="Padding" Value="2,3,2,3"/>
                <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Padding" Value="2,3,2,3"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Grid SnapsToDevicePixels="True">
            <Rectangle Margin="0" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" RadiusX="1" RadiusY="1"/>
            <Rectangle Margin="0" x:Name="InnerBorderHeaderMenu"/>
            <DockPanel>
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="4,0,4,0" x:Name="IconHeaderMenu" VerticalAlignment="Center" ContentSource="Icon"/>
                <Path x:Name="CheckMarkerMenuItem" Visibility="Collapsed" FlowDirection="LeftToRight" Margin="6,0,0,0"  VerticalAlignment="Center" Fill="{TemplateBinding Foreground}" Data="{StaticResource CheckMarker}"/>
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" ContentSource="Header" RecognizesAccessKey="True"/>
            </DockPanel>
            <Popup x:Name="PART_Popup" Focusable="False" AllowsTransparency="True" HorizontalOffset="1" IsOpen="{TemplateBinding IsSubmenuOpen}"
                   Placement="Bottom" PopupAnimation="Scroll" VerticalOffset="-1">
                <ContentControl IsTabStop="False" x:Name="SubmenuBorder" Template="{DynamicResource {ComponentResourceKey ResourceId=SubmenuContent, TypeInTargetAssembly={x:Type FrameworkElement}}}">
                    <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="2" Grid.IsSharedSizeScope="True" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle"/>
                </ContentControl>
            </Popup>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation" Value="True">
                <Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None"/>
            </Trigger>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="IconHeaderMenu" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Visibility" TargetName="CheckMarkerMenuItem" Value="Visible"/>
                <Setter Property="Visibility" TargetName="IconHeaderMenu" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="True">
                <Setter Property="Fill" TargetName="InnerBorderHeaderMenu" Value="{StaticResource BackgroundHoverMenu}"/>
                <Setter Property="Stroke" TargetName="InnerBorderHeaderMenu" Value="{StaticResource BorderMenuItem}"/>
                <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
            </Trigger>
            <Trigger Property="IsSubmenuOpen" Value="True">
                <Setter Property="Fill" TargetName="InnerBorderHeaderMenu" Value="{StaticResource SelectedHeadermenu}"/>
                <Setter Property="Stroke" TargetName="InnerBorderHeaderMenu" Value="{StaticResource BorderMenuItem}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                    </Setter.Value>
                </Setter>
                <Setter Property="Fill" TargetName="CheckMarkerMenuItem" Value="Transparent"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuContent, TypeInTargetAssembly={x:Type FrameworkElement}}" TargetType="{x:Type ContentControl}">
        <Border Background="{StaticResource ControlLightBackground}" BorderBrush="{StaticResource BorderMenuItem}" BorderThickness="1">
            <Grid>
                <Rectangle HorizontalAlignment="Left" Margin="2" Width="28" Fill="{StaticResource IconBackgroundMenuItem}" RadiusX="2" RadiusY="2"/>
                <Rectangle HorizontalAlignment="Left" Margin="30,2,0,2" Width="1" Fill="Transparent"/>
                <Rectangle HorizontalAlignment="Left" Margin="31,2,0,2" Width="1" Fill="Transparent"/>
                <ContentPresenter Margin="2,0"/>
            </Grid>
        </Border>
    </ControlTemplate>
    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Grid SnapsToDevicePixels="True">
            <Rectangle Margin="1" x:Name="BackgroundMenuItem" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" RadiusX="1" RadiusY="1"/>
            <Rectangle Margin="0" x:Name="InnerBorderHeaderMenu" RadiusX="2" RadiusY="2" />
            <DockPanel>
                <ContentPresenter x:Name="IconHeaderMenu" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="4,0,4,0" VerticalAlignment="Center" ContentSource="Icon"/>
                <Path x:Name="CheckMarkerMenuItem" Visibility="Collapsed" FlowDirection="LeftToRight" Margin="6,0,0,0"  VerticalAlignment="Center" Fill="{TemplateBinding Foreground}" Data="{StaticResource CheckMarker}"/>
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" ContentSource="Header" RecognizesAccessKey="True"/>
            </DockPanel>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="IconHeaderMenu" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Visibility" TargetName="CheckMarkerMenuItem" Value="Visible"/>
                <Setter Property="Visibility" TargetName="IconHeaderMenu" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="True">
                <Setter Property="Stroke" TargetName="InnerBorderHeaderMenu" Value="{StaticResource BorderMenuItem}"/>
                <Setter Property="Fill" TargetName="InnerBorderHeaderMenu" Value="Transparent"/>
                <Setter Property="Fill" TargetName="BackgroundMenuItem" Value="Transparent"/>
                <Setter Property="Foreground" Value="#eee"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="True">
                <Setter Property="Fill" TargetName="BackgroundMenuItem" Value="Transparent"/>
                <Setter Property="Stroke" TargetName="InnerBorderHeaderMenu" Value="{StaticResource BorderMenuItem}"/>
                <Setter Property="Fill" TargetName="InnerBorderHeaderMenu" Value="Transparent"/>
                <Setter Property="StrokeDashArray" TargetName="InnerBorderHeaderMenu" Value="1,2"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                    </Setter.Value>
                </Setter>
                <Setter Property="Fill" TargetName="CheckMarkerMenuItem" Value="Transparent"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Grid SnapsToDevicePixels="True">
            <Rectangle x:Name="BackgroundSubmenuItem" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" RadiusX="2" RadiusY="2"/>
            <Rectangle Margin="1" x:Name="InnerBorderSubmenuItem" RadiusX="2" RadiusY="2"/>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="24" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup"/>
                    <ColumnDefinition Width="4"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="37"/>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup"/>
                    <ColumnDefinition Width="17"/>
                </Grid.ColumnDefinitions>
                <ContentPresenter x:Name="IconSubmenu" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="1"  VerticalAlignment="Center" ContentSource="Icon"/>
                <Border Visibility="Hidden" Margin="1" x:Name="CheckedSubmenu" Width="22" Height="22" Background="Transparent">
                    <Path FlowDirection="LeftToRight" x:Name="PathCheckedSubmenu" Width="9" Height="11" Fill="{TemplateBinding Foreground}" Data="{StaticResource CheckMarker}"/>
                </Border>
                <ContentPresenter VerticalAlignment="Center"  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" Grid.Column="2" ContentSource="Header" RecognizesAccessKey="True"/>
                <TextBlock Margin="{TemplateBinding Padding}" Grid.Column="4" Text="{TemplateBinding InputGestureText}"/>
            </Grid>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="IconSubmenu" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Visibility" TargetName="CheckedSubmenu" Value="Visible"/>
                <Setter Property="Visibility" TargetName="IconSubmenu" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="True">
                <Setter Property="Fill" TargetName="BackgroundSubmenuItem" Value="{StaticResource BackgroundHoverSubmenu}"/>
                <Setter Property="Stroke" TargetName="BackgroundSubmenuItem" Value="{StaticResource BorderMenuItem}"/>
                <Setter Property="Stroke" TargetName="InnerBorderSubmenuItem" Value="#ddd"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{StaticResource DisabledForeground2}"/>
                <Setter Property="Fill" TargetName="PathCheckedSubmenu" Value="{StaticResource DisabledBrush}"/>
                <Setter Property="Opacity" TargetName="CheckedSubmenu" Value="0.72"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
        <Grid SnapsToDevicePixels="True">
            <Rectangle x:Name="BackgroundHeaderSubmenu" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" RadiusX="2" RadiusY="2"/>
            <Rectangle Margin="1" x:Name="InnerBorderHeaderSubmenu" Stroke="Transparent" StrokeThickness="1" RadiusX="2" RadiusY="2"/>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="24" Width="Auto" SharedSizeGroup="MenuItemIconColumnGroup"/>
                    <ColumnDefinition Width="4"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="37"/>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup"/>
                    <ColumnDefinition Width="17"/>
                </Grid.ColumnDefinitions>
                <ContentPresenter x:Name="IconHeaderSubmenu" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="1"  VerticalAlignment="Center" ContentSource="Icon"/>
                <Border x:Name="CheckedHeaderSubmenu" Visibility="Hidden" Margin="1"  Width="22" Height="22" Background="Transparent">
                    <Path x:Name="PathCheckedHeaderSubmenu" FlowDirection="LeftToRight"  Width="9" Height="11" Fill="{TemplateBinding Foreground}" Data="{StaticResource CheckMarker}"/>
                </Border>
                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" Grid.Column="2" ContentSource="Header" RecognizesAccessKey="True"/>
                <TextBlock Visibility="Collapsed" Margin="{TemplateBinding Padding}" Grid.Column="4" Text="{TemplateBinding InputGestureText}"/>
                <Path Margin="4,0,0,0" VerticalAlignment="Center" Fill="{TemplateBinding Foreground}" Grid.Column="5" Data="{StaticResource RightArrow}"/>
            </Grid>
            <Popup x:Name="PART_Popup" Focusable="False" AllowsTransparency="True" HorizontalOffset="-2" IsOpen="{TemplateBinding IsSubmenuOpen}"
                   Placement="Right" PopupAnimation="Slide" VerticalOffset="-2" >
                <ContentControl x:Name="SubmenuBorder" IsTabStop="False" Template="{DynamicResource {ComponentResourceKey ResourceId=SubmenuContent, TypeInTargetAssembly={x:Type FrameworkElement}}}" >
                    <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="2" Grid.IsSharedSizeScope="True" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle"/>
                </ContentControl>
            </Popup>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation" Value="True">
                <Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None"/>
            </Trigger>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter Property="Visibility" TargetName="IconHeaderSubmenu" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Visibility" TargetName="CheckedHeaderSubmenu" Value="Visible"/>
                <Setter Property="Visibility" TargetName="IconHeaderSubmenu" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="True">
                <Setter Property="Fill" TargetName="BackgroundHeaderSubmenu" Value="{StaticResource BackgroundHoverSubmenu}"/>
                <Setter Property="Stroke" TargetName="BackgroundHeaderSubmenu" Value="{StaticResource BorderMenuItem}"/>
                <Setter Property="Stroke" TargetName="InnerBorderHeaderSubmenu" Value="#ddd"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{StaticResource DisabledForeground2}"/>
                <Setter Property="Fill" TargetName="PathCheckedHeaderSubmenu" Value="{StaticResource DisabledBrush}"/>
                <Setter Property="Opacity" TargetName="CheckedHeaderSubmenu" Value="0.72"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="Separator">
        <Setter Property="Height" Value="3"/>
        <Setter Property="Margin" Value="30,4,0,4"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Separator">
                    <Border BorderBrush="{StaticResource BorderMenuItem}" BorderThickness="0,1,0,1" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- ContextMenu -->
    <Style TargetType="{x:Type ContextMenu}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Grid.IsSharedSizeScope" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContextMenu}">
                    <Border x:Name="BorderContextMenu" Background="{StaticResource ControlLightBackground}" BorderBrush="{StaticResource ControlBorderBrush}" 
                            BorderThickness="2" CornerRadius="4" >
                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- StatusBar -->
    <Style TargetType="{x:Type StatusBar}">
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Background" Value="{StaticResource ControlBackgroundNormal}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type StatusBar}">
                    <Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Opacity" Value="0.78"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type StatusBarItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type StatusBarItem}">
                    <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
                        <StackPanel Orientation="Horizontal">
                            <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            <Border Width="3" BorderThickness="1,0,1,0" BorderBrush="{StaticResource ControlForeground}" Margin="6,0,2,0"/>
                        </StackPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="TextElement.Foreground" Value="{StaticResource DisabledForeground2}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- Expander -->
    <Style TargetType="{x:Type ToggleButton}" x:Key="ExpanderDownHeaderStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            To="{StaticResource ColorForeground}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            To="{StaticResource ColorForegroundWhite}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Border Padding="{TemplateBinding Padding}" Background="Transparent" BorderThickness="0" x:Name="border">
                        <Grid SnapsToDevicePixels="False" Background="Transparent">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="20" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Border x:Name="Check" Background="Transparent" RenderTransformOrigin="0.5,0.5" BorderThickness="0">
                                <Grid>
                                    <Ellipse x:Name="ellipse" Stroke="{StaticResource ControlActiveBorderBrush}" Width="20" Height="20" StrokeThickness="2"
                                             HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                    <Path x:Name="arrow" Fill="{StaticResource ControlForeground}" Data="M 0 0 L 4 4 L 8 0 Z" VerticalAlignment="Center" 
                                          HorizontalAlignment="Center"/>
                                </Grid>
                                <Border.RenderTransform>
                                    <RotateTransform x:Name="rotate" Angle="0"/>
                                </Border.RenderTransform>
                            </Border>
                            <ContentPresenter x:Name="Content" SnapsToDevicePixels="True" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="1" RecognizesAccessKey="True" Margin="4,0,0,0"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Stroke" TargetName="ellipse" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Opacity" Value="0.82"/>
                            <Setter Property="Foreground" Value="{StaticResource DisabledForeground2}"/>
                            <Setter Property="Opacity" TargetName="ellipse" Value=".6"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="ToggleButton.IsChecked" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard TargetProperty="Angle">
                                        <DoubleAnimation Duration="0:0:1" From="0" To="180" Storyboard.TargetName="rotate" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard TargetProperty="Angle">
                                        <DoubleAnimation Duration="0:0:1" From="180" To="360" Storyboard.TargetName="rotate" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ExpanderRightHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            To="{StaticResource ColorForeground}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            To="{StaticResource ColorForegroundWhite}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Border Padding="{TemplateBinding Padding}" Background="Transparent" BorderThickness="0" x:Name="border">
                        <Grid SnapsToDevicePixels="False" Background="Transparent">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="20" />
                            </Grid.ColumnDefinitions>
                            <Grid.LayoutTransform>
                                <RotateTransform Angle="-90"/>
                            </Grid.LayoutTransform>
                            <Border x:Name="Check" Background="Transparent" RenderTransformOrigin="0.5,0.5" Grid.Column="2">
                                <Grid>
                                    <Ellipse x:Name="ellipse" Stroke="{StaticResource ControlActiveBorderBrush}" Width="20" Height="20" StrokeThickness="2"
                                             HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                    <Path x:Name="arrow" Fill="{StaticResource ControlForeground}" Data="M 0 0 L 4 4 L 8 0 Z" VerticalAlignment="Center" 
                                          HorizontalAlignment="Center"/>
                                </Grid>
                                <Border.RenderTransform>
                                    <RotateTransform x:Name="rotate" Angle="0"/>
                                </Border.RenderTransform>
                            </Border>
                            <ContentPresenter x:Name="Content" SnapsToDevicePixels="True" HorizontalAlignment="Left" Margin="4,3,0,3" Grid.Column="1" VerticalAlignment="Top" RecognizesAccessKey="True">
                                <ContentPresenter.LayoutTransform>
                                    <RotateTransform Angle="90"/>
                                </ContentPresenter.LayoutTransform>
                            </ContentPresenter>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Stroke" TargetName="ellipse" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Opacity" Value="0.82"/>
                            <Setter Property="Foreground" Value="{StaticResource DisabledForeground2}"/>
                            <Setter Property="Opacity" TargetName="ellipse" Value=".6"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="ToggleButton.IsChecked" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard TargetProperty="Angle">
                                        <DoubleAnimation Duration="0:0:1" From="0" To="180" Storyboard.TargetName="rotate" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard TargetProperty="Angle">
                                        <DoubleAnimation Duration="0:0:1" From="180" To="360" Storyboard.TargetName="rotate" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ExpanderUpHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            To="{StaticResource ColorForeground}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            To="{StaticResource ColorForegroundWhite}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Border Padding="{TemplateBinding Padding}" Background="Transparent" BorderThickness="0" x:Name="border">
                        <Grid SnapsToDevicePixels="False" Background="Transparent">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="20" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <Border x:Name="Check" Background="Transparent" RenderTransformOrigin="0.5,0.5">
                                <Grid>
                                    <Ellipse x:Name="ellipse" Stroke="{StaticResource ControlActiveBorderBrush}" Width="20" Height="20" StrokeThickness="2"
                                             HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                    <Path x:Name="arrow" Fill="{StaticResource ControlForeground}" Data="M 0 0 L 4 4 L 8 0 Z" VerticalAlignment="Center" 
                                          HorizontalAlignment="Center"/>
                                </Grid>
                                <Border.RenderTransform>
                                    <RotateTransform x:Name="rotate" Angle="180"/>
                                </Border.RenderTransform>
                            </Border>
                            <ContentPresenter x:Name="Content" SnapsToDevicePixels="True" HorizontalAlignment="Left" Margin="4,3,0,3" VerticalAlignment="Center" Grid.Column="1" RecognizesAccessKey="True"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Stroke" TargetName="ellipse" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Opacity" Value="0.82"/>
                            <Setter Property="Foreground" Value="{StaticResource DisabledForeground2}"/>
                            <Setter Property="Opacity" TargetName="ellipse" Value=".6"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="ToggleButton.IsChecked" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard TargetProperty="Angle">
                                        <DoubleAnimation Duration="0:0:1" From="180" To="360" Storyboard.TargetName="rotate" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard TargetProperty="Angle">
                                        <DoubleAnimation Duration="0:0:1" From="0" To="180" Storyboard.TargetName="rotate" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ExpanderLeftHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            To="{StaticResource ColorForeground}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            To="{StaticResource ColorForegroundWhite}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Border Padding="{TemplateBinding Padding}" Background="Transparent" BorderThickness="0" x:Name="border">
                        <Grid SnapsToDevicePixels="False" Background="Transparent">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="20" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.LayoutTransform>
                                <RotateTransform Angle="90"/>
                            </Grid.LayoutTransform>
                            <Border x:Name="Check" Background="Transparent" RenderTransformOrigin="0.5,0.5" Grid.Column="0">
                                <Grid>
                                    <Ellipse x:Name="ellipse" Stroke="{StaticResource ControlActiveBorderBrush}" Width="20" Height="20" StrokeThickness="2"
                                             HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                    <Path x:Name="arrow" Fill="{StaticResource ControlForeground}" Data="M 0 0 L 4 4 L 8 0 Z" VerticalAlignment="Center" 
                                          HorizontalAlignment="Center"/>
                                </Grid>
                                <Border.RenderTransform>
                                    <RotateTransform x:Name="rotate" Angle="0"/>
                                </Border.RenderTransform>
                            </Border>
                            <ContentPresenter x:Name="Content" SnapsToDevicePixels="True" HorizontalAlignment="Left" Margin="4,3,0,3" VerticalAlignment="Center" Grid.Column="1" RecognizesAccessKey="True">
                                <ContentPresenter.LayoutTransform>
                                    <RotateTransform Angle="-90"/>
                                </ContentPresenter.LayoutTransform>
                            </ContentPresenter>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Fill" TargetName="arrow" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Stroke" TargetName="ellipse" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Opacity" Value="0.82"/>
                            <Setter Property="Foreground" Value="{StaticResource DisabledForeground2}"/>
                            <Setter Property="Opacity" TargetName="ellipse" Value=".6"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="ToggleButton.IsChecked" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard TargetProperty="Angle">
                                        <DoubleAnimation Duration="0:0:1" From="0" To="180" Storyboard.TargetName="rotate" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard TargetProperty="Angle">
                                        <DoubleAnimation Duration="0:0:1" From="180" To="360" Storyboard.TargetName="rotate" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Expander}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4">
                        <DockPanel>
                            <ToggleButton x:Name="ToggleButtonExpander" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" 
                                          FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" 
                                          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" 
                                          VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" FocusVisualStyle="{StaticResource FocusLine}" 
                                          Margin="1,1,1,0" MinHeight="0" MinWidth="0" Style="{StaticResource ExpanderDownHeaderStyle}" 
                                          Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" 
                                          IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Top"
                                          />
                            <Grid Visibility="Collapsed" x:Name="grid" Margin="5,0,0,0">
                                <Border x:Name="border" Background="{StaticResource ControlLightBackground}" BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" CornerRadius="5" Margin="0"/>
                                <ContentPresenter x:Name="ContentExpander" Focusable="False" HorizontalAlignment="Left" Margin="5" VerticalAlignment="Top" DockPanel.Dock="Bottom" />
                                <Grid.OpacityMask>
                                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                        <GradientStop Offset="0" Color="Black"/>
                                        <GradientStop x:Name="grstop_opacity" Offset="0.05" Color="Transparent"/>
                                    </LinearGradientBrush>
                                </Grid.OpacityMask>
                            </Grid>
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard Storyboard.TargetName="grstop_opacity" Storyboard.TargetProperty="Offset">
                                        <DoubleAnimation Duration="0:0:1.5" From="0.05" To="3" />
                                    </Storyboard>
                                </BeginStoryboard>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="grid" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame Value="{x:Static Visibility.Visible}" KeyTime="0:0:0"/>
                                            <DiscreteObjectKeyFrame Value="{x:Static Visibility.Visible}" KeyTime="0:0:1.5"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard Storyboard.TargetName="grstop_opacity" Storyboard.TargetProperty="Offset">
                                        <DoubleAnimation Duration="0:0:1.5" From="3" To="0.05" />
                                    </Storyboard>
                                </BeginStoryboard>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="grid" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame Value="{x:Static Visibility.Visible}" KeyTime="0:0:0"/>
                                            <DiscreteObjectKeyFrame Value="{x:Static Visibility.Collapsed}" KeyTime="0:0:1.5"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Down" >
                            <Setter Property="Margin" TargetName="grid" Value="1,0,1,0"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource DisabledForeground2}" />
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Right">
                            <Setter Property="DockPanel.Dock" TargetName="ContentExpander" Value="Right" />
                            <Setter Property="DockPanel.Dock" TargetName="ToggleButtonExpander" Value="Left" />
                            <Setter Property="Style" TargetName="ToggleButtonExpander" Value="{StaticResource ExpanderRightHeaderStyle}" />
                            <Setter Property="Background" TargetName="border" Value="{StaticResource BackgroundExpanderRight}"/>
                            <Setter Property="Margin" TargetName="grid" Value="0,1,0,1"/>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Up">
                            <Setter Property="DockPanel.Dock" TargetName="ContentExpander" Value="Top" />
                            <Setter Property="DockPanel.Dock" TargetName="ToggleButtonExpander" Value="Bottom" />
                            <Setter Property="Style" TargetName="ToggleButtonExpander" Value="{StaticResource ExpanderUpHeaderStyle}" />
                            <Setter Property="Background" TargetName="border" Value="{StaticResource BackgroundExpanderBottom}"/>
                            <Setter Property="Margin" TargetName="grid" Value="1,0,1,0"/>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Left">
                            <Setter Property="DockPanel.Dock" TargetName="ContentExpander" Value="Left" />
                            <Setter Property="DockPanel.Dock" TargetName="ToggleButtonExpander" Value="Right" />
                            <Setter Property="Style" TargetName="ToggleButtonExpander" Value="{StaticResource ExpanderLeftHeaderStyle}" />
                            <Setter Property="Background" TargetName="border" Value="{StaticResource BackgroundExpanderLeft}"/>
                            <Setter Property="Margin" TargetName="grid" Value="0,1,0,1"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- ListBox -->
    <Style TargetType="{x:Type ListBox}">
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBox}">
                    <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="4">
                        <ScrollViewer>
                            <ItemsPresenter Margin="4" />
                        </ScrollViewer>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{StaticResource DisabledBrush}" TargetName="border"/>
                            <Setter Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" TargetName="border"/>
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="True">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ListBoxItem}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="content"
                                            To="{StaticResource ColorForeground}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Duration="0:0:0.3" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="content"
                                            To="{StaticResource ColorForegroundWhite}"/>
                        </Storyboard>
                        <Storyboard x:Key="SelectedOn">
                            <DoubleAnimation Duration="0:0:0.3" Storyboard.TargetName="selected_bg" Storyboard.TargetProperty="(FrameworkElement.Opacity)"
                                             To="1"/>
                        </Storyboard>
                        <Storyboard x:Key="SelectedOff">
                            <DoubleAnimation Duration="0:0:0.3" Storyboard.TargetName="selected_bg" Storyboard.TargetProperty="(FrameworkElement.Opacity)"
                                             To="0"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid Background="{TemplateBinding Background}" Margin="1,1,1,1" SnapsToDevicePixels="True" x:Name="grid">
                        <Rectangle x:Name="bg" IsHitTestVisible="False" Fill="Transparent"/>
                        <Rectangle x:Name="selected_bg" IsHitTestVisible="False" Opacity="0">
                            <Rectangle.Fill>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop Offset="0" Color="{StaticResource HighlightComboBoxItem1}"/>
                                    <GradientStop Offset="1" Color="{StaticResource HighlightComboBoxItem2}"/>
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <ContentPresenter x:Name="content" Margin="3" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True"/>
                                <Condition Property="IsSelected" Value="False"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                                <BeginStoryboard Storyboard="{StaticResource SelectedOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource SelectedOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- Slider -->
    <Style x:Key="HorizontalSliderThumb" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Height" Value="18"/>
        <Setter Property="Width" Value="18"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="center" Storyboard.TargetProperty="(Ellipse.Height)">
                                <DoubleAnimation.To>
                                    <system:Double>10</system:Double>
                                </DoubleAnimation.To>
                            </DoubleAnimation>
                            <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="center" Storyboard.TargetProperty="(Ellipse.Width)">
                                <DoubleAnimation.To>
                                    <system:Double>10</system:Double>
                                </DoubleAnimation.To>
                            </DoubleAnimation>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="center" Storyboard.TargetProperty="(Ellipse.Height)">
                                <DoubleAnimation.To>
                                    <system:Double>14</system:Double>
                                </DoubleAnimation.To>
                            </DoubleAnimation>
                            <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="center" Storyboard.TargetProperty="(Ellipse.Width)">
                                <DoubleAnimation.To>
                                    <system:Double>14</system:Double>
                                </DoubleAnimation.To>
                            </DoubleAnimation>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid Background="Transparent">
                        <Ellipse Stretch="Fill" Fill="{StaticResource ControlForegroundWhite}"/>
                        <Ellipse x:Name="center" Width="14" Height="14" VerticalAlignment="Center" HorizontalAlignment="Center" Fill="{StaticResource ControlActiveBorderBrush}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Fill" TargetName="center" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Opacity" Value=".8"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RepeatButtonLeft" TargetType="{x:Type RepeatButton}" BasedOn="{x:Null}">
        <Setter Property="Height" Value="6"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid>
                        <Border x:Name="bg" Background="{StaticResource BrushTrackProgressBar}" CornerRadius="2"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" TargetName="bg" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Opacity" Value=".8"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RepeatButtonRight" TargetType="{x:Type RepeatButton}" BasedOn="{x:Null}">
        <Setter Property="Height" Value="6"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid>
                        <Border x:Name="bg" Background="{StaticResource ControlBackgroundNormal}" CornerRadius="2"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" TargetName="bg" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Opacity" Value=".8"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Slider}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusLine2}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Slider}">
                    <Grid x:Name="GridRoot">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <TickBar Visibility="Collapsed" x:Name="TopTick" Height="5" SnapsToDevicePixels="True" Placement="Top" Fill="{TemplateBinding Foreground}"/>
                        <Border Grid.Row="1" Margin="0" x:Name="Border" Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/>
                        <Canvas Grid.Row="1" VerticalAlignment="Center" Margin="0,0,0,4">
                            <Rectangle Fill="{StaticResource SliderSelectRange}" x:Name="PART_SelectionRange" Height="6" Visibility="Hidden" />
                        </Canvas>
                        <Track Grid.Row="1" x:Name="PART_Track">
                            <Track.Thumb>
                                <Thumb x:Name="thumb" Style="{StaticResource HorizontalSliderThumb}"/>
                            </Track.Thumb>
                            <Track.IncreaseRepeatButton>
                                <RepeatButton x:Name="LeftRB" Style="{DynamicResource RepeatButtonRight}" Command="Slider.IncreaseLarge"/>
                            </Track.IncreaseRepeatButton>
                            <Track.DecreaseRepeatButton>
                                <RepeatButton x:Name="RightRB" Style="{DynamicResource RepeatButtonLeft}" Command="Slider.DecreaseLarge"/>
                            </Track.DecreaseRepeatButton>
                        </Track>
                        <TickBar Visibility="Collapsed" Grid.Row="2" x:Name="BottomTick" Height="5" SnapsToDevicePixels="True" Placement="Bottom" Fill="{TemplateBinding Foreground}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TickPlacement" Value="TopLeft">
                            <Setter Property="Visibility" Value="Visible" TargetName="TopTick"/>
                        </Trigger>
                        <Trigger Property="TickPlacement" Value="BottomRight">
                            <Setter Property="Visibility" Value="Visible" TargetName="BottomTick"/>
                        </Trigger>
                        <Trigger Property="TickPlacement" Value="Both">
                            <Setter Property="Visibility" Value="Visible" TargetName="TopTick"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="BottomTick"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource DisabledForeground2}"/>
                            <Setter Property="Opacity" Value="0.62"/>
                        </Trigger>
                        <Trigger Property="Orientation" Value="Vertical">
                            <Setter Property="LayoutTransform" TargetName="GridRoot">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="PART_Track" Property="Orientation" Value="Horizontal"/>
                        </Trigger>
                        <Trigger Property="IsSelectionRangeEnabled" Value="True">
                            <Setter Property="Visibility" TargetName="PART_SelectionRange" Value="Visible"/>
                            <Setter Property="Opacity" TargetName="LeftRB" Value="0.8"/>
                            <Setter Property="Opacity" TargetName="RightRB" Value="0.8"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="BorderThickness" Value="1"/>
    </Style>

    <!-- Calendar -->
    <Style TargetType="{x:Type Calendar}">
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CalendarButtonStyle" Value="{DynamicResource CalendarButtonStyle}" />
        <Setter Property="CalendarDayButtonStyle" Value="{DynamicResource CalendarDayButtonStyle}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Calendar}">
                    <StackPanel x:Name="PART_Root" HorizontalAlignment="Center">
                        <CalendarItem x:Name="PART_CalendarItem" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type CalendarItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CalendarItem}">
                    <ControlTemplate.Resources>
                        <DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
                            <TextBlock x:Name="txt" Foreground="{StaticResource ControlForeground}" FontWeight="Bold" FontSize="9.5" FontFamily="Verdana" HorizontalAlignment="Center" Margin="0,4,0,4" Text="{Binding}" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </ControlTemplate.Resources>
                    <Grid x:Name="PART_Root">
                        <Border Margin="0,2,0,2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" CornerRadius="3">
                            <Border BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="2" CornerRadius="1">
                                <Grid>
                                    <Grid.Resources>
                                        <ControlTemplate x:Key="PreviousButtonTemplate" TargetType="{x:Type Button}">
                                            <Grid Cursor="Hand" Background="Transparent">
                                                <Path x:Name="path" Height="10" HorizontalAlignment="Center" VerticalAlignment="Center"
                                                          Width="6" Stretch="Fill" Data="M288.75,232.25 L288.75,240.625 L283,236.625 z">
                                                    <Path.Fill>
                                                        <SolidColorBrush Color="{StaticResource ColorForegroundWhite}"/>
                                                    </Path.Fill>
                                                </Path>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Trigger.EnterActions>
                                                        <BeginStoryboard>
                                                            <Storyboard>
                                                                <ColorAnimation Storyboard.TargetName="path" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                                                                        Duration="0:0:0.3" To="{StaticResource BorderBrushGradientColor2}"/>
                                                            </Storyboard>
                                                        </BeginStoryboard>
                                                    </Trigger.EnterActions>
                                                    <Trigger.ExitActions>
                                                        <BeginStoryboard>
                                                            <Storyboard>
                                                                <ColorAnimation Storyboard.TargetName="path" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                                                                        Duration="0:0:0.3" To="{StaticResource ColorForegroundWhite}"/>
                                                            </Storyboard>
                                                        </BeginStoryboard>
                                                    </Trigger.ExitActions>
                                                </Trigger>
                                                <Trigger Property="IsEnabled" Value="False">
                                                    <Setter Property="Fill" Value="Black" TargetName="path"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                        <ControlTemplate x:Key="NextButtonTemplate" TargetType="{x:Type Button}">
                                            <Grid Cursor="Hand">
                                                <Path x:Name="path" Height="10" HorizontalAlignment="Center" VerticalAlignment="Center"
                                                      Width="6" Stretch="Fill" Data="M282.875,231.875 L282.875,240.375 L288.625,236 z">
                                                    <Path.Fill>
                                                        <SolidColorBrush Color="{StaticResource ColorForegroundWhite}"/>
                                                    </Path.Fill>
                                                </Path>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Trigger.EnterActions>
                                                        <BeginStoryboard>
                                                            <Storyboard>
                                                                <ColorAnimation Storyboard.TargetName="path" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                                                                        Duration="0:0:0.3" To="{StaticResource BorderBrushGradientColor2}"/>
                                                            </Storyboard>
                                                        </BeginStoryboard>
                                                    </Trigger.EnterActions>
                                                    <Trigger.ExitActions>
                                                        <BeginStoryboard>
                                                            <Storyboard>
                                                                <ColorAnimation Storyboard.TargetName="path" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                                                                        Duration="0:0:0.3" To="{StaticResource ColorForegroundWhite}"/>
                                                            </Storyboard>
                                                        </BeginStoryboard>
                                                    </Trigger.ExitActions>
                                                </Trigger>
                                                <Trigger Property="IsEnabled" Value="False">
                                                    <Setter Property="Fill" Value="Black" TargetName="path"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                        <ControlTemplate x:Key="HeaderButtonTemplate" TargetType="{x:Type Button}">
                                            <Grid Cursor="Hand" Background="Transparent">
                                                <ContentControl x:Name="buttonContent" IsTabStop="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" 
                                                                ContentTemplate="{TemplateBinding ContentTemplate}" Margin="10,3,10,3" Foreground="{StaticResource ControlForegroundWhite}"/>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Trigger.EnterActions>
                                                        <BeginStoryboard>
                                                            <Storyboard>
                                                                <ColorAnimation Storyboard.TargetName="buttonContent" 
                                                                                Storyboard.TargetProperty="(ContentControl.Foreground).(SolidColorBrush.Color)"
                                                                        Duration="0:0:0.3" To="{StaticResource ColorForeground}"/>
                                                            </Storyboard>
                                                        </BeginStoryboard>
                                                    </Trigger.EnterActions>
                                                    <Trigger.ExitActions>
                                                        <BeginStoryboard>
                                                            <Storyboard>
                                                                <ColorAnimation Storyboard.TargetName="buttonContent"
                                                                                Storyboard.TargetProperty="(ContentControl.Foreground).(SolidColorBrush.Color)"
                                                                        Duration="0:0:0.3" To="{StaticResource ColorForegroundWhite}"/>
                                                            </Storyboard>
                                                        </BeginStoryboard>
                                                    </Trigger.ExitActions>
                                                </Trigger>
                                                <Trigger Property="IsEnabled" Value="False">
                                                    <Setter Property="Foreground" TargetName="buttonContent" Value="Black"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Grid.Resources>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Button x:Name="PART_PreviousButton" Grid.Column="0" Grid.Row="0" Focusable="False" HorizontalAlignment="Left" Height="20" 
                                            Template="{StaticResource PreviousButtonTemplate}" Width="25"/>
                                    <Button x:Name="PART_HeaderButton" Grid.Column="1" Grid.Row="0" FontWeight="Bold" Focusable="False" FontSize="10.5" 
                                            HorizontalAlignment="Center" Template="{StaticResource HeaderButtonTemplate}" VerticalAlignment="Center"/>
                                    <Button x:Name="PART_NextButton" Grid.Column="2" Grid.Row="0" Focusable="False" HorizontalAlignment="Right" Height="20" 
                                            Template="{StaticResource NextButtonTemplate}" Width="25"/>
                                    <Grid x:Name="PART_MonthView" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="6,3,6,6" Grid.Row="1" Visibility="Visible">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                    </Grid>
                                    <Grid x:Name="PART_YearView" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="6,3,7,6" Grid.Row="1" Visibility="Hidden">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                    </Grid>
                                </Grid>
                            </Border>
                        </Border>
                        <Rectangle x:Name="PART_DisabledVisual" Margin="0,2,0,2" Fill="{StaticResource DisabledBrush}" Opacity="0.6" RadiusY="2" RadiusX="2" Stretch="Fill" StrokeThickness="0" Visibility="Collapsed"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Visibility" TargetName="PART_DisabledVisual" Value="Visible"/>
                        </Trigger>
                        <DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Year">
                            <Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden"/>
                            <Setter Property="Visibility" TargetName="PART_YearView" Value="Visible"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Decade">
                            <Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden"/>
                            <Setter Property="Visibility" TargetName="PART_YearView" Value="Visible"/>
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CalendarButtonStyle" TargetType="{x:Type CalendarButton}">
        <Setter Property="Background" Value="{StaticResource HoverBackgroundCalendar}"/>
        <Setter Property="MinWidth" Value="40"/>
        <Setter Property="MinHeight" Value="42"/>
        <Setter Property="FontSize" Value="10"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CalendarButton}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.2"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value=".5"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.4"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Unselected"/>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SelectedBackground" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="selectedText" Storyboard.TargetProperty="Color">
                                            <SplineColorKeyFrame KeyTime="0" Value="{StaticResource ColorForeground}"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ActiveStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Active"/>
                                <VisualState x:Name="Inactive">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="selectedText" Storyboard.TargetProperty="Color">
                                            <SplineColorKeyFrame KeyTime="0" Value="#FF777777"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CalendarButtonFocusStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="CalendarButtonFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="CalendarButtonFocusVisual">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="CalendarButtonUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="CalendarButtonFocusVisual">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="SelectedBackground" Opacity="0" Fill="{TemplateBinding Background}" RadiusX="3" RadiusY="3" Stroke="{StaticResource ControlActiveBorderBrush}"/>
                        <Rectangle x:Name="Background" Opacity="0" Fill="{TemplateBinding Background}" RadiusX="3" RadiusY="3" Stroke="{StaticResource ControlBorderBrush}"/>
                        <ContentControl x:Name="NormalText" FontSize="{TemplateBinding FontSize}" IsTabStop="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                        Margin="1,0,1,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" 
                                        ContentTemplate="{TemplateBinding ContentTemplate}">
                            <ContentControl.Foreground>
                                <SolidColorBrush x:Name="selectedText" Color="#FFCCCCCC"/>
                            </ContentControl.Foreground>
                        </ContentControl>
                        <Rectangle x:Name="CalendarButtonFocusVisual" IsHitTestVisible="False" Visibility="Collapsed" Stroke="{StaticResource ControlActiveBorderBrush}" RadiusX="3" RadiusY="3"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter Property="Visibility" TargetName="CalendarButtonFocusVisual" Value="Visible"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}">
        <Setter Property="Background" Value="{StaticResource HoverBackgroundCalendar}"/>
        <Setter Property="Foreground" Value="Lime"/>
        <Setter Property="MinWidth" Value="5"/>
        <Setter Property="MinHeight" Value="5"/>
        <Setter Property="FontSize" Value="10"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CalendarDayButton}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.1"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.45"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.3"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="NormalText" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value=".35"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Unselected"/>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SelectedBackground" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value=".75"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="selectedText" Storyboard.TargetProperty="Color">
                                            <SplineColorKeyFrame KeyTime="0" Value="{StaticResource ColorForeground}"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CalendarButtonFocusStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="CalendarButtonFocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="CalendarButtonUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DayButtonFocusVisual">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ActiveStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Active"/>
                                <VisualState x:Name="Inactive">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="selectedText" Storyboard.TargetProperty="Color">
                                            <SplineColorKeyFrame KeyTime="0" Value="#FF777777"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="DayStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="RegularDay"/>
                                <VisualState x:Name="Today">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="TodayBackground"/>
                                        <ColorAnimation Duration="0" To="{StaticResource ColorForegroundWhite}" Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="NormalText"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="BlackoutDayStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="NormalDay"/>
                                <VisualState x:Name="BlackoutDay">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Blackout"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="TodayBackground" Opacity="0" Fill="{StaticResource TodayBackgroundBrush}" RadiusX="3" RadiusY="3" Stroke="{StaticResource ControlBorderBrush}"/>
                        <Rectangle x:Name="SelectedBackground" Opacity="0" Fill="{TemplateBinding Background}" RadiusX="3" RadiusY="3" Stroke="{StaticResource ControlBorderBrush}"/>
                        <Rectangle x:Name="Background" Opacity="0" Fill="{TemplateBinding Background}" RadiusX="3" RadiusY="3" Stroke="{StaticResource ControlBorderBrush}"/>
                        <ContentControl x:Name="NormalText" FontSize="{TemplateBinding FontSize}" IsTabStop="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                        Margin="5,0,5,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" 
                                        ContentTemplate="{TemplateBinding ContentTemplate}">
                            <ContentControl.Foreground>
                                <SolidColorBrush Color="#FFCCCDDD" x:Name="selectedText"/>
                            </ContentControl.Foreground>
                        </ContentControl>
                        <Path x:Name="Blackout" HorizontalAlignment="Stretch" Margin="3" VerticalAlignment="Stretch" Opacity="0" RenderTransformOrigin="0.5,0.5" Fill="{StaticResource ControlForeground}" Stretch="Fill" 
                              Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z"/>
                        <Rectangle x:Name="DayButtonFocusVisual" IsHitTestVisible="False" Visibility="Collapsed" Stroke="{StaticResource ControlForegroundWhite}" RadiusX="3" RadiusY="3"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DatePicker -->
    <Style TargetType="{x:Type DatePicker}">
        <Setter Property="IsTodayHighlighted" Value="True"/>
        <Setter Property="SelectedDateFormat" Value="Short"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Padding" Value="2"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="CalendarStyle">
            <Setter.Value>
                <Style TargetType="{x:Type Calendar}" BasedOn="{StaticResource {x:Type Calendar}}"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DatePicker}">
                    <Grid x:Name="PART_Root" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                        <Grid.Resources>
                            <ControlTemplate x:Key="DropDownButtonTemplate" TargetType="{x:Type Button}">
                                <Grid>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualStateGroup.Transitions>
                                                <VisualTransition GeneratedDuration="0"/>
                                                <VisualTransition GeneratedDuration="0:0:0.1" To="MouseOver"/>
                                                <VisualTransition GeneratedDuration="0:0:0.1" To="Pressed"/>
                                                <VisualTransition From="Normal" GeneratedDuration="00:00:00.3000000" To="MouseOver"/>
                                                <VisualTransition From="MouseOver" GeneratedDuration="00:00:00.5000000" To="Normal"/>
                                                <VisualTransition From="Pressed" GeneratedDuration="00:00:00.5000000" To="MouseOver"/>
                                                <VisualTransition From="MouseOver" GeneratedDuration="00:00:00.3000000" To="Pressed"/>
                                            </VisualStateGroup.Transitions>
                                            <VisualState x:Name="Normal"/>
                                            <VisualState x:Name="MouseOver">
                                                <Storyboard>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Pressed">
                                                <Storyboard>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.7"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.65"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Grid Background="#11FFFFFF" FlowDirection="LeftToRight" HorizontalAlignment="Center" Height="18" Margin="0" VerticalAlignment="Center" Width="19">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="20*"/>
                                            <ColumnDefinition Width="20*"/>
                                            <ColumnDefinition Width="20*"/>
                                            <ColumnDefinition Width="20*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="23*"/>
                                            <RowDefinition Height="19*"/>
                                            <RowDefinition Height="19*"/>
                                            <RowDefinition Height="19*"/>
                                        </Grid.RowDefinitions>
                                        <Border x:Name="Background" Margin="0" Opacity="1" Grid.ColumnSpan="4" Grid.Row="1" Grid.RowSpan="3" 
                                                Background="{StaticResource ControlBackgroundNormal}" CornerRadius=".5"/>
                                        <Border x:Name="HoverBorder" BorderBrush="{x:Null}" BorderThickness="1" CornerRadius="0,0,1,1" Grid.ColumnSpan="4" 
                                                Grid.RowSpan="4" Background="{StaticResource HoverBackgroundCalendar}" Opacity="0"/>
                                        <Rectangle Grid.ColumnSpan="4" Grid.RowSpan="1" StrokeThickness="1" Fill="{StaticResource ControlLightBackground}" />
                                        <Path HorizontalAlignment="Center" Margin="4,3" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" 
                                              Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="1" Grid.RowSpan="3" Fill="{StaticResource ControlForeground}" Stretch="Fill" 
                                              Data="M11.426758,8.4305077 L11.749023,8.4305077 L11.749023,16.331387 L10.674805,16.331387 L10.674805,10.299648 L9.0742188,11.298672 L9.0742188,10.294277 C9.4788408,10.090176 9.9094238,9.8090878 10.365967,9.4510155 C10.82251,9.0929432 11.176106,8.7527733 11.426758,8.4305077 z M14.65086,8.4305077 L18.566387,8.4305077 L18.566387,9.3435936 L15.671368,9.3435936 L15.671368,11.255703 C15.936341,11.058764 16.27293,10.960293 16.681133,10.960293 C17.411602,10.960293 17.969301,11.178717 18.354229,11.615566 C18.739157,12.052416 18.931622,12.673672 18.931622,13.479336 C18.931622,15.452317 18.052553,16.438808 16.294415,16.438808 C15.560365,16.438808 14.951641,16.234707 14.468243,15.826504 L14.881817,14.929531 C15.368796,15.326992 15.837872,15.525723 16.289043,15.525723 C17.298809,15.525723 17.803692,14.895514 17.803692,13.635098 C17.803692,12.460618 17.305971,11.873379 16.310528,11.873379 C15.83071,11.873379 15.399232,12.079271 15.016094,12.491055 L14.65086,12.238613 z"/>
                                        <Ellipse Height="3" HorizontalAlignment="Center" VerticalAlignment="Center" Width="3" Grid.ColumnSpan="4" Fill="{StaticResource ControlForegroundWhite}" StrokeThickness="0"/>
                                        <Border x:Name="DisabledVisual" Opacity="0" Grid.ColumnSpan="4" Grid.Row="0" Grid.RowSpan="4" BorderBrush="{StaticResource DisabledBorderBrush}"
                                                BorderThickness="1" CornerRadius="0,0,.5,.5" Background="{StaticResource DisabledBrush}"/>
                                    </Grid>
                                </Grid>
                            </ControlTemplate>
                        </Grid.Resources>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Button x:Name="PART_Button" Grid.Column="1" Foreground="{TemplateBinding Foreground}" Focusable="False" HorizontalAlignment="Left" Margin="3,0,3,0" Grid.Row="0" Template="{StaticResource DropDownButtonTemplate}" VerticalAlignment="Center" Width="20"/>
                        <DatePickerTextBox x:Name="PART_TextBox" Grid.Row="0" Grid.Column="0" VerticalContentAlignment="Center" Height="{TemplateBinding Height}"/>
                        <Grid x:Name="PART_DisabledVisual" Grid.ColumnSpan="2" Grid.Column="0" IsHitTestVisible="False" Opacity="0" Grid.Row="0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Rectangle Grid.Column="0" Fill="#a6FFFFFF" RadiusY="1" Grid.Row="0" RadiusX="1"/>
                            <Rectangle Grid.Column="1" Fill="#a6FFFFFF" Height="18" Margin="3,0,3,0" RadiusY="1" Grid.Row="0" RadiusX="1" Width="19"/>
                            <Popup x:Name="PART_Popup" AllowsTransparency="True" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type DatePickerTextBox}">
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="CaretBrush" Value="{StaticResource ControlForeground}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DatePickerTextBox}">
                    <Grid>
                        <Border x:Name="Border" Opacity="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
                            <Grid>
                                <Border BorderThickness="1" CornerRadius="1">
                                    <Border.BorderBrush>
                                        <SolidColorBrush Color="Transparent" x:Name="MouseOverColor"/>
                                    </Border.BorderBrush>
                                    <ScrollViewer Margin="0" x:Name="PART_ContentHost" Background="{TemplateBinding Background}"/>
                                </Border>
                            </Grid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter Property="BorderBrush" Value="{StaticResource ControlActiveBorderBrush}" TargetName="Border"/>
                            <Setter Property="BorderThickness" Value="1.8" TargetName="Border"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" Value="{StaticResource ControlActiveBorderBrush}" TargetName="Border"/>
                            <Setter Property="BorderThickness" Value="1.8" TargetName="Border"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{StaticResource DisabledBrush}" />
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Text" Value="--/--/--"/>
                            <Setter Property="HorizontalContentAlignment" Value="Center"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- ListView -->
    <Style TargetType="{x:Type ListView}">
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}" />
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListView}">
                    <Border x:Name="Bd" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2" 
                            BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                        <ScrollViewer Padding="{TemplateBinding Padding}" Style="{DynamicResource {x:Static GridView.GridViewScrollViewerStyleKey}}">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsGrouping" Value="True">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource DisabledBrush}" />
                            <Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource DisabledBorderBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="{x:Type ScrollViewer}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid SnapsToDevicePixels="True" Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <DockPanel Margin="{TemplateBinding Padding}">
                            <ScrollViewer Focusable="False" DockPanel.Dock="Top" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                                <GridViewHeaderRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="2,0,2,0" 
                                                            AllowsColumnReorder="{Binding Path=TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}" 
                                                            ColumnHeaderContainerStyle="{Binding Path=TemplatedParent.View.ColumnHeaderContainerStyle, RelativeSource={RelativeSource TemplatedParent}}" 
                                                            ColumnHeaderContextMenu="{Binding Path=TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}" 
                                                            ColumnHeaderTemplate="{Binding Path=TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}" 
                                                            ColumnHeaderTemplateSelector="{Binding Path=TemplatedParent.View.ColumnHeaderTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}" 
                                                            ColumnHeaderToolTip="{Binding Path=TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}" 
                                                            Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}" />
                            </ScrollViewer>
                            <ScrollContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ScrollContentPresenter"
                                                    Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" 
                                                    CanContentScroll="{TemplateBinding CanContentScroll}" KeyboardNavigation.DirectionalNavigation="Local" />
                        </DockPanel>
                        <ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_HorizontalScrollBar"
                                   Grid.Row="1" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}" Maximum="{TemplateBinding ScrollableWidth}" 
                                   Minimum="0.0" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
                        <ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_VerticalScrollBar" 
                                   Grid.Column="1" Orientation="Vertical" ViewportSize="{TemplateBinding ViewportHeight}" Maximum="{TemplateBinding ScrollableHeight}" 
                                   Minimum="0.0" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
                        <DockPanel Grid.Column="1" Grid.Row="1" Background="{Binding Path=Background, ElementName=PART_VerticalScrollBar}" LastChildFill="False">
                            <Rectangle Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Width="1" Fill="White" DockPanel.Dock="Left" />
                            <Rectangle Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Height="1" Fill="White" DockPanel.Dock="Top" />
                        </DockPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ListViewItemFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Stroke="{StaticResource ControlActiveBorderBrush}" StrokeDashArray="1 2" StrokeThickness="1.5" RadiusX="2" RadiusY="2" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ListViewItem}">
        <Setter Property="FocusVisualStyle" Value="{DynamicResource ListViewItemFocusVisual}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Foreground" Value="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}}}"/>
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Margin" Value="0,0,0,1" />
        <Setter Property="Padding" Value="5,2" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListViewItem}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Duration="0:0:0.2" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="row_content"
                                            To="{StaticResource ColorForeground}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Duration="0:0:0.2" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="row_content"
                                            To="{StaticResource ColorForegroundWhite}"/>
                        </Storyboard>
                        <Storyboard x:Key="SelectedOn">
                            <DoubleAnimation Duration="0:0:0.2" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="HoverSelected" To="1"/>
                        </Storyboard>
                        <Storyboard x:Key="SelectedOff">
                            <DoubleAnimation Duration="0:0:0.2" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="HoverSelected" To="0"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Border SnapsToDevicePixels="True" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2" x:Name="border">
                        <Grid Margin="2,0">
                            <Rectangle x:Name="Background" IsHitTestVisible="False" Fill="{TemplateBinding Background}" RadiusX="0"
                                       Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"/>
                            <Rectangle x:Name="HoverSelected" IsHitTestVisible="False" Opacity="0" RadiusX="0">
                                <Rectangle.Fill>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                        <GradientStop Offset="0" Color="{StaticResource HighlightComboBoxItem1}"/>
                                        <GradientStop Offset="1" Color="{StaticResource HighlightComboBoxItem2}"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <Border Background="Transparent">
                                <GridViewRowPresenter x:Name="row_content" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Stretch" Margin="0,2" />
                            </Border>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource SelectedOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource SelectedOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="Selector.IsSelected" Value="False" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground3}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style x:Key="GridViewColumnHeaderGripper" TargetType="{x:Type Thumb}">
        <Setter Property="Canvas.Right" Value="-8.5" />
        <Setter Property="Width" Value="18" />
        <Setter Property="Height" Value="{Binding Path=ActualHeight, RelativeSource={RelativeSource TemplatedParent}}" />
        <Setter Property="Padding" Value="0,3,0,4" />
        <Setter Property="Background" Value="{StaticResource ControlForegroundWhite}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Padding="{TemplateBinding Padding}" Background="#00FFFFFF">
                        <Rectangle HorizontalAlignment="Center" Width=".5" Fill="White"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="{x:Type GridViewColumnHeader}" TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Background" Value="{StaticResource ControlBackgroundNormal}" />
        <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
        <Setter Property="MinHeight" Value="24"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="PressedOn">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Main" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value=".8"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="PressedOff">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Main" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid Margin="0,1">
                        <Grid>
                            <Border x:Name="Main" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" 
                                    Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderThickness}" CornerRadius="0" />
                            <Border x:Name="HoverBorder" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" 
                                    Background="{StaticResource ControlBackgroundLine}" BorderBrush="{x:Null}" CornerRadius="0" Opacity="0" />
                            <Border BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" BorderBrush="{StaticResource ControlForegroundWhite}">
                                <ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                  RecognizesAccessKey="True" Margin="2" />
                            </Border>
                        </Grid>
                        <Canvas>
                            <Thumb x:Name="PART_HeaderGripper" Style="{StaticResource GridViewColumnHeaderGripper}" HorizontalAlignment="Stretch" />
                        </Canvas>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard"/>
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource PressedOff}" x:Name="PressedOff_BeginStoryboard"/>
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource PressedOn}" x:Name="PressedOn_BeginStoryboard"/>
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="Height" Value="Auto">
                            <Setter Property="MinHeight" Value="24" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource DisabledForeground2}" />
                            <Setter Property="Opacity" TargetName="Main" Value=".6"/>
                        </Trigger>
                        <Trigger Property="Role" Value="Padding">
                            <Setter TargetName="PART_HeaderGripper" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="Role" Value="Floating">
                            <Setter TargetName="PART_HeaderGripper" Property="Visibility" Value="Collapsed" />
                            <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- TreeView -->
    <Style TargetType="{x:Type TreeView}">
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeView}">
                    <Grid>
                        <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{DynamicResource SolidBorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
                            <ScrollViewer Focusable="False" Padding="4" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="False">
                                <ItemsPresenter/>
                            </ScrollViewer>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{StaticResource DisabledBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TreeViewItemToggleButton" TargetType="{x:Type ToggleButton}">
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="CheckedOn">
                            <DoubleAnimation Storyboard.TargetName="rotate" Storyboard.TargetProperty="(RotateTransform.Angle)" Duration="0:0:0.4"
                                             To="90"/>
                        </Storyboard>
                        <Storyboard x:Key="CheckedOff">
                            <DoubleAnimation Storyboard.TargetName="rotate" Storyboard.TargetProperty="(RotateTransform.Angle)" Duration="0:0:0.4"
                                             To="0"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Storyboard.TargetName="expand_path" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                                            Duration="0:0:0.3" To="{StaticResource ColorForegroundWhite}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Storyboard.TargetName="expand_path" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                                            Duration="0:0:0.3" To="{StaticResource ColorForeground}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid Width="16" Height="16" Background="Transparent">
                        <Path x:Name="expand_path" HorizontalAlignment="Center" Margin="1"  VerticalAlignment="Center" Data="M 0 0 L 4 4 L 0 8 Z"
                              RenderTransformOrigin="0.5,0.5">
                            <Path.Fill>
                                <SolidColorBrush Color="{StaticResource ColorForeground}"/>
                            </Path.Fill>
                            <Path.LayoutTransform>
                                <RotateTransform x:Name="rotate" Angle="0"/>
                            </Path.LayoutTransform>
                        </Path>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource CheckedOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource CheckedOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Fill" TargetName="expand_path">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="{x:Type TreeViewItem}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="Padding" Value="1,0,0,0"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeViewItem}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <ColorAnimation Storyboard.TargetName="PART_Header" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            Duration="0:0:0.3" To="{StaticResource ColorForeground}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <ColorAnimation Storyboard.TargetName="PART_Header" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            Duration="0:0:0.3" To="{StaticResource ColorForegroundWhite}"/>
                        </Storyboard>
                        <Storyboard x:Key="SelectedOn">
                            <DoubleAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetName="selected" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.1" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="SelectedOff">
                            <DoubleAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetName="selected" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="SelectedHoverOn">
                            <DoubleAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetName="selected_hover" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="SelectedHoverOff">
                            <DoubleAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetName="selected_hover" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="18" Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <ToggleButton x:Name="Expander" Style="{DynamicResource TreeViewItemToggleButton}" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" 
                                      ClickMode="Press"/>
                        <Border Grid.Column="1" x:Name="Selection_Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                            <Grid>
                                <Border x:Name="selected" Opacity="0">
                                    <Border.Background>
                                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                            <GradientStop Offset="0" Color="{StaticResource HighlightComboBoxItem1}"/>
                                            <GradientStop Offset="1" Color="{StaticResource HighlightComboBoxItem2}"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                </Border>
                                <ContentPresenter x:Name="PART_Header" HorizontalAlignment="Stretch" ContentSource="Header" Margin="5,4"/>
                                <Border x:Name="selected_hover" Opacity="0" Background="{StaticResource ControlBackgroundLine}" BorderBrush="{x:Null}" BorderThickness="1" CornerRadius="2"/>
                            </Grid>
                        </Border>
                        <ItemsPresenter Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" x:Name="ItemsHost"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True"/>
                                <Condition Property="IsMouseOver" Value="True"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource SelectedHoverOn}"/>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource SelectedHoverOff}"/>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <Trigger Property="IsExpanded" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ItemsHost"/>
                        </Trigger>
                        <Trigger Property="HasItems" Value="False">
                            <Setter Property="Visibility" Value="Hidden" TargetName="Expander"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource SelectedOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource SelectedOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="False"/>
                                <Condition Property="IsMouseOver" SourceName="Selection_Border" Value="True"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True"/>
                                <Condition Property="IsSelectionActive" Value="False"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="{StaticResource ControlForeground}" TargetName="Selection_Border"/>
                            <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- DataGrid -->
    <Style TargetType="{x:Type DataGrid}">
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="GridLinesVisibility" Value="None"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGrid}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" 
                            Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True" CornerRadius="2">
                        <ScrollViewer x:Name="DG_ScrollViewer" Focusable="False">
                            <ScrollViewer.Template>
                                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Grid.Resources>
                                            <ControlTemplate x:Key="SelectAllButtonTemplate" TargetType="{x:Type Button}">
                                                <ControlTemplate.Resources>
                                                    <Storyboard x:Key="HoverOn">
                                                        <ColorAnimation Storyboard.TargetName="path" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                                                                        Duration="0:0:0.3" To="{StaticResource ColorForeground}"/>
                                                    </Storyboard>
                                                    <Storyboard x:Key="HoverOff">
                                                        <ColorAnimation Storyboard.TargetName="path" Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
                                                                        Duration="0:0:0.3" To="{StaticResource ColorForegroundWhite}"/>
                                                    </Storyboard>
                                                    <Storyboard x:Key="PressedOn">
                                                        <DoubleAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                            <SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="0.6"/>
                                                        </DoubleAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                    <Storyboard x:Key="PressedOff">
                                                        <DoubleAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                            <SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                                                        </DoubleAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </ControlTemplate.Resources>
                                                <Grid x:Name="Grid">
                                                    <Border x:Name="Background" Background="{StaticResource ControlBackgroundNormal}" BorderThickness="0">
                                                        <Path x:Name="path" Fill="{StaticResource ControlForegroundWhite}" Data="F 1 M -2,8 L 6,8 6,0 Z" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                                    </Border>
                                                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                                                </Grid>
                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="IsDefault" Value="True">
                                                        <Setter Property="BorderBrush" TargetName="Background" Value="{StaticResource ControlBorderBrush}"/>
                                                    </Trigger>
                                                    <Trigger Property="IsMouseOver" Value="True">
                                                        <Trigger.EnterActions>
                                                            <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                                                        </Trigger.EnterActions>
                                                        <Trigger.ExitActions>
                                                            <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                                                        </Trigger.ExitActions>
                                                    </Trigger>
                                                    <Trigger Property="IsPressed" Value="True">
                                                        <Trigger.EnterActions>
                                                            <BeginStoryboard Storyboard="{StaticResource PressedOn}"/>
                                                        </Trigger.EnterActions>
                                                        <Trigger.ExitActions>
                                                            <BeginStoryboard Storyboard="{StaticResource PressedOff}"/>
                                                        </Trigger.ExitActions>
                                                    </Trigger>
                                                    <Trigger Property="IsEnabled" Value="False">
                                                        <Setter Property="Background" Value="{StaticResource DisabledBrush}" TargetName="Background"/>
                                                        <Setter Property="Fill" TargetName="path">
                                                            <Setter.Value>
                                                                <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Trigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Grid.Resources>
                                        <Button Width="23" Margin="0,-1,0,0" Template="{StaticResource SelectAllButtonTemplate}" 
                                                Command="{x:Static DataGrid.SelectAllCommand}" Focusable="False" 
                                                Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
                                        <Border Grid.Column="1" Margin="-2,-3,-2,-2" BorderThickness="2" Background="{StaticResource ControlBackgroundNormal}">
                                            <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" 
                                                                            Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
                                        </Border>
                                        <Rectangle Grid.Column="2" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Fill="Transparent"/>
                                        <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Grid.ColumnSpan="2" Grid.Row="1" Margin="1,0" 
                                                                CanContentScroll="{TemplateBinding CanContentScroll}"/>
                                        <ScrollBar x:Name="PART_VerticalScrollBar" Grid.Column="2" Grid.Row="1" Maximum="{TemplateBinding ScrollableHeight}" 
                                                   Orientation="Vertical" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" 
                                                   Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                                   ViewportSize="{TemplateBinding ViewportHeight}"/>
                                        <Grid Grid.Column="1" Grid.Row="2">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="{Binding NonFrozenColumnsViewportHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
                                                <ColumnDefinition Width="*"/>
                                            </Grid.ColumnDefinitions>
                                            <ScrollBar x:Name="PART_HorizontalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableWidth}" 
                                                       Orientation="Horizontal" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" 
                                                       Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                                       ViewportSize="{TemplateBinding ViewportWidth}"/>
                                        </Grid>
                                    </Grid>
                                </ControlTemplate>
                            </ScrollViewer.Template>
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsGrouping" Value="True">
                <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
            </Trigger>
        </Style.Triggers>
    </Style>


    <Style TargetType="{x:Type DataGridCell}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Padding" Value="3"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Cursor" Value="Arrow"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Grid x:Name="Root" Background="Transparent">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CurrentStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Regular"/>
                                <VisualState x:Name="Current">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value=".9"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Editing">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="VerticalSeparator" Width="1" Fill="{StaticResource ControlForegroundWhite}" />
                        <Rectangle x:Name="FocusVisual" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                                   IsHitTestVisible="False" Opacity="0" Fill="Transparent"
                                   StrokeThickness="0,0,0,2" Stroke="#FF111111"/>
                        <ContentPresenter Grid.Column="1" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                          Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                                          Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style TargetType="{x:Type DataGridRow}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
        <Setter Property="ValidationErrorTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <TextBlock Foreground="Red" Margin="2,0,0,0" Text="!" VerticalAlignment="Center"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridRow}">
                    <SelectiveScrollingGrid Margin="0,1,0,0" Background="{TemplateBinding Background}">
                        <SelectiveScrollingGrid.Resources>
                            <Storyboard x:Key="DetailsVisibleTransition">
                                <DoubleAnimation Duration="00:00:0.1" Storyboard.TargetName="DetailsPresenter" Storyboard.TargetProperty="ContentHeight"/>
                            </Storyboard>
                        </SelectiveScrollingGrid.Resources>
                        <SelectiveScrollingGrid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </SelectiveScrollingGrid.ColumnDefinitions>
                        <SelectiveScrollingGrid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </SelectiveScrollingGrid.RowDefinitions>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0"/>
                                    <VisualTransition From="Normal" GeneratedDuration="00:00:00.3000000" To="MouseOver"/>
                                    <VisualTransition From="MouseOver" GeneratedDuration="00:00:00.5000000" To="Normal"/>
                                    <VisualTransition From="Normal" GeneratedDuration="00:00:00.3000000" To="MouseOver_Selected"/>
                                    <VisualTransition From="MouseOver_Selected" GeneratedDuration="00:00:00.5000000" To="Normal"/>
                                    <VisualTransition From="Normal" GeneratedDuration="00:00:00.3000000" To="Normal_Selected"/>
                                    <VisualTransition From="Normal_Selected" GeneratedDuration="00:00:00.5000000" To="Normal"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Normal_AlternatingRow" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="HoverRectangle"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Normal_Selected">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="SelectedRectangle"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver_Selected">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="HoverRectangle"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="SelectedRectangle"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused_Selected">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="SelectedRectangle"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="BackgroundRectangle" Grid.ColumnSpan="2" Grid.RowSpan="2" Fill="{StaticResource ControlLightBackground}"/>
                        <Rectangle x:Name="SelectedRectangle" Fill="{StaticResource ControlActiveBorderBrush}" Opacity="0" Grid.ColumnSpan="2" Grid.RowSpan="2" />
                        <Rectangle x:Name="HoverRectangle" Fill="{StaticResource ControlBackgroundPressed}" Opacity="0" Grid.ColumnSpan="2" Grid.RowSpan="2"/>
                        <DataGridRowHeader x:Name="RowHeader" Grid.RowSpan="3" SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" 
                                           Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
                        <DataGridCellsPresenter x:Name="CellsPresenter" Grid.Column="1" ItemsPanel="{TemplateBinding ItemsPanel}" 
                                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        <DataGridDetailsPresenter x:Name="DetailsPresenter" Grid.Column="1" Grid.Row="1" 
                                                  SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" 
                                                  Visibility="{TemplateBinding DetailsVisibility}"/>
                    </SelectiveScrollingGrid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style x:Key="RowHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Height" Value="4" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Cursor" Value="SizeNS" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <BooleanToVisibilityConverter x:Key="boolConverter" />

    <Style TargetType="{x:Type DataGridRowHeader}">
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="SeparatorBrush" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="SeparatorVisibility" Value="Collapsed"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridRowHeader}">
                    <Grid x:Name="Root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="00:00:0.2"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="HoverRectangle"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver_CurrentRow_Selected">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="SelectedRectangle"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="HoverRectangle"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Normal_CurrentRow">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="SelectedRectangle"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Normal_Selected">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="grid"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Normal_EditingRow">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CurrentRowGlyph" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="EditingRowGlyph" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="grid"
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border>
                            <Grid x:Name="grid" Height="Auto" Width="Auto">
                                <Rectangle Stretch="Fill" Fill="{StaticResource ControlLightBackground}"/>
                                <Rectangle x:Name="SelectedRectangle" Stretch="Fill" Fill="{StaticResource ControlBackgroundPressed}" Opacity="0"/>
                                <Rectangle x:Name="HoverRectangle" Stretch="Fill" Fill="{StaticResource ControlBackgroundLine}" Opacity="0"/>
                            </Grid>
                        </Border>
                        <StackPanel Orientation="Horizontal">
                            <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                              Content="{TemplateBinding Content}"/>
                            <Control SnapsToDevicePixels="False" Template="{Binding ValidationErrorTemplate, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}"
                                         Visibility="{Binding (Validation.HasError), Converter={StaticResource boolConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" />
                        </StackPanel>
                        <Path x:Name="CurrentRowGlyph" Height="10" HorizontalAlignment="Center" Margin="8,0,8,0" VerticalAlignment="Center" Width="6" 
                              Opacity="0" Stretch="Fill" 
                              Data="F1 M 511.047,352.682L 511.047,342.252L 517.145,347.467L 511.047,352.682 Z " Fill="{StaticResource ControlForeground}"/>
                        <Path x:Name="EditingRowGlyph" Height="10" HorizontalAlignment="Center" Margin="8,0,8,0" VerticalAlignment="Center" Width="6" 
                              Opacity="0" Stretch="Fill" 
                              Data="F1 M 511.047,352.682L 511.047,342.252L 517.145,347.467L 511.047,352.682 Z " Fill="{StaticResource ControlForeground}"/>
                        <Thumb x:Name="PART_TopHeaderGripper" Style="{StaticResource RowHeaderGripperStyle}" VerticalAlignment="Top" />
                        <Thumb x:Name="PART_BottomHeaderGripper" Style="{StaticResource RowHeaderGripperStyle}" VerticalAlignment="Bottom" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Cursor" Value="SizeWE" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="FontSize" Value="10"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="SeparatorBrush" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Padding" Value="4,4,5,4"/>
        <Setter Property="MinHeight" Value="26"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <Grid x:Name="Root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="00:00:0.1"/>
                                    <VisualTransition From="Normal" GeneratedDuration="00:00:00.3000000" To="MouseOver"/>
                                    <VisualTransition From="MouseOver" GeneratedDuration="00:00:00.5000000" To="Normal"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" 
                                                                       Storyboard.TargetName="HoverRectangle" 
                                                                       Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SortStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="00:00:0.2"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Unsorted"/>
                                <VisualState x:Name="SortAscending">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1.0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="SortDescending">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SortIcon" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1.0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SortIconTransform" Storyboard.TargetProperty="ScaleY">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="-.9"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <StackPanel x:Name="VerticalSeparator" Grid.RowSpan="2" Orientation="Horizontal">
                            <Rectangle VerticalAlignment="Stretch" Width="1" Visibility="{TemplateBinding SeparatorVisibility}" Fill="{TemplateBinding SeparatorBrush}"/>
                        </StackPanel>
                        <Rectangle x:Name="BackgroundRectangle" Grid.Column="1" Grid.ColumnSpan="2" Grid.RowSpan="2" Fill="{TemplateBinding Background}"/>
                        <Rectangle x:Name="HoverRectangle" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="3" Stretch="Fill" 
                                   Fill="{StaticResource ControlBackgroundLine}" Opacity="0"/>
                        <ContentPresenter Grid.Column="1" Grid.RowSpan="2" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                          Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                                          Content="{TemplateBinding Content}"/>
                        <Path x:Name="SortIcon" Grid.Column="2" Grid.RowSpan="2" HorizontalAlignment="Left" VerticalAlignment="Center" Width="8" 
                              Opacity="0" RenderTransformOrigin=".5,.5" Fill="{StaticResource ControlForegroundWhite}" Stretch="Uniform" Margin="0,0,8,0"
                              Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z ">
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform x:Name="SortIconTransform" ScaleX=".9" ScaleY=".9"/>
                                </TransformGroup>
                            </Path.RenderTransform>
                        </Path>
                        <Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}" 
                               Grid.RowSpan="3" />
                        <Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"
                               Grid.RowSpan="3" Grid.Column="2"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Background" Value="{StaticResource DisabledBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type DataGridColumnHeadersPresenter}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeadersPresenter}">
                    <Grid>
                        <DataGridColumnHeader x:Name="PART_FillerColumnHeader" IsHitTestVisible="False" />
                        <ItemsPresenter />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- ToolBar -->
    <Style x:Key="ToolBarButtonBaseStyle" TargetType="{x:Type ButtonBase}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusLine}"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Padding" Value="5"/>
        <Setter Property="Margin" Value="0,2"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Storyboard.TargetName="Hover" Storyboard.TargetProperty="(FrameworkElement.Opacity)" Duration="0:0:0.3" To="1"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Storyboard.TargetName="Hover" Storyboard.TargetProperty="(FrameworkElement.Opacity)" Duration="0:0:0.3" To="0"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Border x:Name="Bg" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                         <Grid>
                             <Border x:Name="Hover" Background="{StaticResource ControlLightBackground}" Opacity="0"/>
                             <ContentPresenter RecognizesAccessKey="True" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                         </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Bg" Property="Background" Value="{StaticResource DisabledBrush}"/>
                            <Setter TargetName="Bg" Property="Opacity" Value=".95"/>
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Static ToolBar.ButtonStyleKey}" BasedOn="{StaticResource ToolBarButtonBaseStyle}" TargetType="{x:Type Button}" />
    <Style x:Key="{x:Static ToolBar.ToggleButtonStyleKey}" BasedOn="{StaticResource ToolBarButtonBaseStyle}" TargetType="{x:Type ToggleButton}" />
    <Style x:Key="{x:Static ToolBar.CheckBoxStyleKey}" BasedOn="{StaticResource ToolBarButtonBaseStyle}" TargetType="{x:Type CheckBox}">
        <Style.Triggers>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Background" Value="{StaticResource ToolBarCheckedButton}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style x:Key="{x:Static ToolBar.RadioButtonStyleKey}" BasedOn="{StaticResource ToolBarButtonBaseStyle}" TargetType="{x:Type RadioButton}">
        <Style.Triggers>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Background" Value="{StaticResource ToolBarCheckedButton}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="{x:Static ToolBar.ComboBoxStyleKey}" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource {x:Type ComboBox}}"/>
    <Style x:Key="{x:Static ToolBar.TextBoxStyleKey}" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}"/>

    <Style x:Key="ToolBarThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border x:Name="brd" SnapsToDevicePixels="True" Background="Transparent" Padding="{TemplateBinding Padding}" CornerRadius="0">
                        <Rectangle>
                            <Rectangle.Fill>
                                <DrawingBrush TileMode="Tile" Viewbox="0,0,4,4" ViewboxUnits="Absolute" Viewport="0,0,4,4" ViewportUnits="Absolute">
                                    <DrawingBrush.Drawing>
                                        <DrawingGroup>
                                            <GeometryDrawing x:Name="gd1" Brush="{StaticResource ControlForeground}" Geometry="M 1 1 L 1 3 L 3 3 L 3 1 z"/>
                                            <GeometryDrawing x:Name="gd2" Brush="{StaticResource ControlForeground}" Geometry="M 0 0 L 0 2 L 2 2 L 2 0 z"/>
                                        </DrawingGroup>
                                    </DrawingBrush.Drawing>
                                </DrawingBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Cursor" Value="SizeAll"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ToolBarHorizontalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="MinHeight" Value="0"/>
        <Setter Property="MinWidth" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Storyboard.TargetName="hover" Storyboard.TargetProperty="(FrameworkElement.Opacity)" Duration="0:0:0.3" To=".8"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Storyboard.TargetName="hover" Storyboard.TargetProperty="(FrameworkElement.Opacity)" Duration="0:0:0.3" To="0"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid x:Name="Bd" Background="{StaticResource SelectedBackgroundBrushToolBar}">
                        <Border x:Name="hover" Background="{StaticResource ControlActiveBorderBrush}" Opacity="0"/>
                        <Canvas SnapsToDevicePixels="True" HorizontalAlignment="Right" Margin="7,2,2,2" VerticalAlignment="Bottom" Width="6" Height="7">
                            <Path Stroke="White" Data="M 1 1.5 L 6 1.5"/>
                            <Path Stroke="{TemplateBinding Foreground}" Data="M 0 0.5 L 5 0.5"/>
                            <Path Fill="White" Data="M 0.5 4 L 6.5 4 L 3.5 7 Z"/>
                            <Path Fill="{TemplateBinding Foreground}" Data="M -0.5 3 L 5.5 3 L 2.5 6 Z"/>
                        </Canvas>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsKeyboardFocused" Value="True">
                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource ControlActiveBorderBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ToolBarVerticalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="MinHeight" Value="0"/>
        <Setter Property="MinWidth" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Storyboard.TargetName="hover" Storyboard.TargetProperty="(FrameworkElement.Opacity)" Duration="0:0:0.3" To=".8"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Storyboard.TargetName="hover" Storyboard.TargetProperty="(FrameworkElement.Opacity)" Duration="0:0:0.3" To="0"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid SnapsToDevicePixels="True" x:Name="Bd" Background="{StaticResource SelectedBackgroundBrushToolBar}">
                        <Border x:Name="hover" Background="{StaticResource ControlActiveBorderBrush}" Opacity="0"/>
                        <Canvas SnapsToDevicePixels="True" HorizontalAlignment="Right" Margin="2,7,2,2" VerticalAlignment="Bottom" Width="7" Height="6">
                            <Path Stroke="White" Data="M 1.5 1 L 1.5 6"/>
                            <Path Stroke="{TemplateBinding Foreground}" Data="M 0.5 0 L 0.5 5"/>
                            <Path Fill="White" Data="M 3.5 0.5 L 7 3.5 L 4 6.5 Z"/>
                            <Path Fill="{TemplateBinding Foreground}" Data="M 3 -0.5 L 6 2.5 L 3 5.5 Z"/>
                        </Canvas>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsKeyboardFocused" Value="True">
                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource ControlActiveBorderBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ToolBar}">
        <Setter Property="Background" Value="{StaticResource ControlBackgroundNormal}"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToolBar}">
                    <Grid SnapsToDevicePixels="True" Margin="3,1,1,1" x:Name="Grid">
                        <Grid HorizontalAlignment="Right" x:Name="OverflowGrid">
                            <ToggleButton IsEnabled="{TemplateBinding HasOverflowItems}" FocusVisualStyle="{x:Null}" x:Name="OverflowButton" 
                                          Style="{StaticResource ToolBarHorizontalOverflowButtonStyle}" ClickMode="Press" 
                                          IsChecked="{Binding Path=IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <Popup Focusable="False" AllowsTransparency="True" IsOpen="{Binding Path=IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}" 
                                   Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" 
                                   StaysOpen="False" x:Name="OverflowPopup">
                                <Border x:Name="Shdw">
                                    <Border BorderThickness="1" Background="{StaticResource ControlBackgroundNormal}" BorderBrush="{StaticResource ControlBorderBrush}">
                                        <ToolBarOverflowPanel x:Name="PART_ToolBarOverflowPanel" Focusable="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                                              FocusVisualStyle="{x:Null}" Margin="2"  WrapWidth="200" KeyboardNavigation.DirectionalNavigation="Cycle" 
                                                              KeyboardNavigation.TabNavigation="Cycle"/>
                                    </Border>
                                </Border>
                            </Popup>
                        </Grid>
                        <Border Margin="0,0,11,0" x:Name="MainPanelBorder" BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0" Padding="{TemplateBinding Padding}" 
                                Background="{TemplateBinding Background}">
                            <Grid>
                                <DockPanel KeyboardNavigation.TabIndex="1" KeyboardNavigation.TabNavigation="Local">
                                    <Thumb Padding="6,5,1,5" Margin="-3,0,0,0" x:Name="ToolBarThumb" Style="{StaticResource ToolBarThumbStyle}" Width="10"/>
                                    <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Center" Margin="4,0,4,0" 
                                                      x:Name="ToolBarHeader" VerticalAlignment="Center" ContentSource="Header"/>
                                    <ToolBarPanel x:Name="PART_ToolBarPanel" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0,1,2,2"  
                                                  IsItemsHost="True" Background="{TemplateBinding Background}"/>
                                </DockPanel>
                            </Grid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsOverflowOpen" Value="True">
                            <Setter Property="IsEnabled" TargetName="ToolBarThumb" Value="False"/>
                        </Trigger>
                        <Trigger Property="Header" Value="{x:Null}">
                            <Setter Property="Visibility" TargetName="ToolBarHeader" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="ToolBarTray.IsLocked" Value="True">
                            <Setter Property="Visibility" TargetName="ToolBarThumb" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="HasDropShadow" SourceName="OverflowPopup" Value="True">
                            <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
                            <Setter Property="SnapsToDevicePixels" TargetName="Shdw" Value="True"/>
                        </Trigger>
                        <Trigger Property="Orientation" Value="Vertical">
                            <Setter Property="Margin" TargetName="Grid" Value="1,3,1,1"/>
                            <Setter Property="Style" TargetName="OverflowButton" Value="{StaticResource ToolBarVerticalOverflowButtonStyle}"/>
                            <Setter Property="Height" TargetName="ToolBarThumb" Value="10"/>
                            <Setter Property="Width" TargetName="ToolBarThumb" Value="Auto"/>
                            <Setter Property="Margin" TargetName="ToolBarThumb" Value="-1,-3,0,0"/>
                            <Setter Property="Padding" TargetName="ToolBarThumb" Value="5,6,6,1"/>
                            <Setter Property="Margin" TargetName="ToolBarHeader" Value="0,0,0,4"/>
                            <Setter Property="Margin" TargetName="PART_ToolBarPanel" Value="1,0,2,2"/>
                            <Setter Property="DockPanel.Dock" TargetName="ToolBarThumb" Value="Top"/>
                            <Setter Property="DockPanel.Dock" TargetName="ToolBarHeader" Value="Top"/>
                            <Setter Property="HorizontalAlignment" TargetName="OverflowGrid" Value="Stretch"/>
                            <Setter Property="VerticalAlignment" TargetName="OverflowGrid" Value="Bottom"/>
                            <Setter Property="Placement" TargetName="OverflowPopup" Value="Right"/>
                            <Setter Property="Margin" TargetName="MainPanelBorder" Value="0,0,0,11"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{StaticResource DisabledBrush}"/>
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource DisabledForeground}"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- Frame -->
    <Style x:Key="FrameButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Command" Value="NavigationCommands.BrowseBack"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Storyboard.TargetName="Rect" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:0.3" To="1"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Storyboard.TargetName="Rect" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:0.3" To="0"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Rectangle x:Name="Rect" RadiusX="2" RadiusY="2" Width="24" Height="24" Fill="{StaticResource ControlLightBackground}"
                                   Opacity="0"/>
                        <Path x:Name="Arrow" Margin="0,0,1,0" Fill="{StaticResource ControlForeground}" HorizontalAlignment="Center" 
                              VerticalAlignment="Center" Data="M 0 8 L 7 15 L 7 10 L 16 10 L 16 6 L 7 6 L 7 1 Z" StrokeLineJoin="Round"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Command" Value="{x:Static NavigationCommands.BrowseForward}">
                            <Setter TargetName="Arrow" Property="Data" Value="M 16 8 L 9 1 L 9 10 L 0 10 L 0 6 L 9 6 L 9 15 Z"/>
                            <Setter TargetName="Arrow" Property="Margin" Value="1,0,0,0"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="Rect" Property="Fill" Value="{StaticResource PressedBackgroundButtonFrame}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Rect" Property="Opacity" Value="0"/>
                            <Setter TargetName="Arrow" Property="Fill" Value="{StaticResource DisabledArrowFrame}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FrameMenu" TargetType="{x:Type Menu}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
        <Setter Property="IsMainMenu" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Menu}">
                    <DockPanel IsItemsHost="True"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FrameHeaderMenuItem" TargetType="{x:Type MenuItem}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type MenuItem}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Storyboard.TargetName="Bg" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:0.3" To="1"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Storyboard.TargetName="Bg" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:0.3" To="0"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Popup x:Name="PART_Popup" Placement="Bottom" VerticalOffset="2" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" 
                               Focusable="False" PopupAnimation="Scroll">
                            <Border Name="SubMenuBorder" Background="{StaticResource ControlLightBackground}" BorderThickness="1" 
                                    BorderBrush="{StaticResource ControlBorderBrush}">
                                <StackPanel IsItemsHost="True" Margin="2" KeyboardNavigation.TabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Cycle"/>
                            </Border>
                        </Popup>
                        <Grid x:Name="Panel" Width="24" Background="Transparent" HorizontalAlignment="Right" >
                            <Border Name="Bg"  Background="{StaticResource ControlLightBackground}" CornerRadius="2" Opacity="0"/>
                            <Path x:Name="Arrow" SnapsToDevicePixels="False" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,2,4,0"
                                  Fill="{StaticResource ControlForeground}" StrokeLineJoin="Round" Data="M 0 0 L 4 4 L 8 0 Z"/>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHighlighted" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsSubmenuOpen" Value="True">
                            <Setter TargetName="Panel" Property="Background" Value="{StaticResource PressedBackgroundButtonFrame}" />
                            <Setter TargetName="Arrow" Property="Fill" Value="{StaticResource ControlForegroundWhite}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Arrow" Property="Fill"  Value="{StaticResource DisabledArrowFrame}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FrameSubmenuItem" TargetType="{x:Type MenuItem}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Header" Value="{Binding Path=(JournalEntry.Name)}"/>
        <Setter Property="Command" Value="NavigationCommands.NavigateJournal"/>
        <Setter Property="CommandTarget" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Menu}}, Path=TemplatedParent}"/>
        <Setter Property="CommandParameter" Value="{Binding RelativeSource={RelativeSource Self}}"/>
        <Setter Property="JournalEntryUnifiedViewConverter.JournalEntryPosition" Value="{Binding (JournalEntryUnifiedViewConverter.JournalEntryPosition)}"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type MenuItem}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Storyboard.TargetName="hover" Storyboard.TargetProperty="(FrameworkElement.Opacity)" Duration="0:0:0.3" To="1"/>
                            <ColorAnimation Storyboard.TargetName="content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            Duration="0:0:0.4" To="{StaticResource ColorForeground}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Storyboard.TargetName="hover" Storyboard.TargetProperty="(FrameworkElement.Opacity)" Duration="0:0:0.3" To="0"/>
                            <ColorAnimation Storyboard.TargetName="content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            Duration="0:0:0.4" To="{StaticResource ColorForegroundWhite}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid Name="Panel" Background="Transparent" SnapsToDevicePixels="True">
                        <Border x:Name="hover" Opacity="0">
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop Offset="0" Color="{StaticResource HighlightComboBoxItem1}"/>
                                    <GradientStop Offset="1" Color="{StaticResource HighlightComboBoxItem2}"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                        <Path Name="Check" SnapsToDevicePixels="False"  Margin="7,5" Width="10" Height="10" HorizontalAlignment="Left"
                              StrokeStartLineCap="Triangle" StrokeEndLineCap="Triangle" StrokeThickness="2" 
                              Stroke="{StaticResource ControlForegroundWhite}" />
                        <ContentPresenter x:Name="content" ContentSource="Header" Margin="24,5,50,5"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="JournalEntryUnifiedViewConverter.JournalEntryPosition" Value="Current">
                            <Setter TargetName="Check" Property="Data" Value="M 0,5 L 2.5,8 L 7,3 "/>
                        </Trigger>
                        <Trigger Property="IsHighlighted" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                            <Setter Property="Stroke" TargetName="Check" Value="{StaticResource ControlForeground}"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="MenuItem.IsHighlighted" Value="True"/>
                                <Condition Property="JournalEntryUnifiedViewConverter.JournalEntryPosition" Value="Forward"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Check" Property="Data" Value="M 3 1 L 7 5 L 3 9 z"/>
                            <Setter TargetName="Check" Property="Fill" Value="{StaticResource ControlForeground}"/>
                            <Setter TargetName="Check" Property="Stroke" Value="{x:Null}"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="MenuItem.IsHighlighted" Value="True"/>
                                <Condition Property="JournalEntryUnifiedViewConverter.JournalEntryPosition" Value="Back"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Check" Property="Data" Value="M 7 1 L 3 5 L 7 9 z"/>
                            <Setter TargetName="Check" Property="Fill" Value="{StaticResource ControlForeground}"/>
                            <Setter TargetName="Check" Property="Stroke" Value="{x:Null}"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <JournalEntryUnifiedViewConverter x:Key="JournalEntryUnifiedViewConverter"/>

    <Style TargetType="{x:Type Frame}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Frame}">
                    <Border Background="Transparent" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="2">
                        <DockPanel>
                            <Grid x:Name="grid" DockPanel.Dock="Top" Height="28" Background="{StaticResource ControlBackgroundNormal}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="16"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Menu Name="NavMenu" Grid.Column="2" Height="16" Margin="1,0,0,0" VerticalAlignment="Center" 
                                      Style="{StaticResource FrameMenu}">
                                    <MenuItem Style="{StaticResource FrameHeaderMenuItem}" ItemContainerStyle="{StaticResource FrameSubmenuItem}"
                                              IsSubmenuOpen="{Binding Path=(MenuItem.IsSubmenuOpen),Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}">
                                        <MenuItem.ItemsSource>
                                            <MultiBinding Converter="{StaticResource JournalEntryUnifiedViewConverter}">
                                                <MultiBinding.Bindings>
                                                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="BackStack" />
                                                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ForwardStack" />
                                                </MultiBinding.Bindings>
                                            </MultiBinding>
                                        </MenuItem.ItemsSource>
                                    </MenuItem>
                                </Menu>
                                <Button Style="{StaticResource FrameButtonStyle}" Command="NavigationCommands.BrowseBack" Margin="2,0,0,0" Grid.Column="0"/>
                                <Button Style="{StaticResource FrameButtonStyle}" Command="NavigationCommands.BrowseForward" Margin="2,0,0,0" Grid.Column="1"/>
                            </Grid>
                            <Grid>
                                <Border Background="{TemplateBinding Background}"/>
                                <ContentPresenter x:Name="PART_FrameCP"/>
                            </Grid>
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="CanGoForward" Value="False"/>
                                <Condition Property="CanGoBack" Value="False"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="NavMenu" Property="IsEnabled" Value="False"/>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value=".7"/>
                            <Setter Property="Background" TargetName="grid" Value="{StaticResource DisabledBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- NavigationWindow -->
    <Style x:Key="NavigationWindowButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Command" Value="NavigationCommands.BrowseBack"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Storyboard.TargetName="Rect" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:0.3" To="1"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Storyboard.TargetName="Rect" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:0.3" To="0"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Rectangle x:Name="Rect" RadiusX="2" RadiusY="2" Width="24" Height="24" Fill="{StaticResource ControlLightBackground}"
                                   Opacity="0"/>
                        <Path x:Name="Arrow" Margin="0,0,1,0" Fill="{StaticResource ControlForeground}" HorizontalAlignment="Center" 
                              VerticalAlignment="Center" Data="M 0 8 L 7 15 L 7 10 L 16 10 L 16 6 L 7 6 L 7 1 Z" StrokeLineJoin="Round"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Command" Value="{x:Static NavigationCommands.BrowseForward}">
                            <Setter TargetName="Arrow" Property="Data" Value="M 16 8 L 9 1 L 9 10 L 0 10 L 0 6 L 9 6 L 9 15 Z"/>
                            <Setter TargetName="Arrow" Property="Margin" Value="1,0,0,0"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="Rect" Property="Fill" Value="{StaticResource PressedBackgroundButtonFrame}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Rect" Property="Opacity" Value="0"/>
                            <Setter TargetName="Arrow" Property="Fill" Value="{StaticResource DisabledArrowFrame}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="NavigationWindowMenu" TargetType="{x:Type Menu}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
        <Setter Property="IsMainMenu" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Menu}">
                    <DockPanel IsItemsHost="True"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="NavigationWindowHeaderMenuItem" TargetType="{x:Type MenuItem}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type MenuItem}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Storyboard.TargetName="Bg" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:0.3" To="1"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Storyboard.TargetName="Bg" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:0.3" To="0"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Popup x:Name="PART_Popup" Placement="Bottom" VerticalOffset="2" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" 
                               Focusable="False" PopupAnimation="Scroll">
                            <Border Name="SubMenuBorder" Background="{StaticResource ControlLightBackground}" BorderThickness="1" 
                                    BorderBrush="{StaticResource ControlBorderBrush}">
                                <StackPanel IsItemsHost="True" Margin="2" KeyboardNavigation.TabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Cycle"/>
                            </Border>
                        </Popup>
                        <Grid x:Name="Panel" Width="24" Background="Transparent" HorizontalAlignment="Right" >
                            <Border Name="Bg"  Background="{StaticResource ControlLightBackground}" CornerRadius="2" Opacity="0"/>
                            <Path x:Name="Arrow" SnapsToDevicePixels="False" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,2,4,0"
                                  Fill="{StaticResource ControlForeground}" StrokeLineJoin="Round" Data="M 0 0 L 4 4 L 8 0 Z"/>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHighlighted" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsSubmenuOpen" Value="True">
                            <Setter TargetName="Panel" Property="Background" Value="{StaticResource PressedBackgroundButtonFrame}" />
                            <Setter TargetName="Arrow" Property="Fill" Value="{StaticResource ControlForegroundWhite}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Arrow" Property="Fill"  Value="{StaticResource DisabledArrowFrame}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="NavigationWindowSubmenuItem" TargetType="{x:Type MenuItem}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Header" Value="{Binding Path=(JournalEntry.Name)}"/>
        <Setter Property="Command" Value="NavigationCommands.NavigateJournal"/>
        <Setter Property="CommandTarget" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Menu}}, Path=TemplatedParent}"/>
        <Setter Property="CommandParameter" Value="{Binding RelativeSource={RelativeSource Self}}"/>
        <Setter Property="JournalEntryUnifiedViewConverter.JournalEntryPosition" Value="{Binding (JournalEntryUnifiedViewConverter.JournalEntryPosition)}"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type MenuItem}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Storyboard.TargetName="hover" Storyboard.TargetProperty="(FrameworkElement.Opacity)" Duration="0:0:0.3" To="1"/>
                            <ColorAnimation Storyboard.TargetName="content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            Duration="0:0:0.4" To="{StaticResource ColorForeground}"/>
                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Storyboard.TargetName="hover" Storyboard.TargetProperty="(FrameworkElement.Opacity)" Duration="0:0:0.3" To="0"/>
                            <ColorAnimation Storyboard.TargetName="content" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            Duration="0:0:0.4" To="{StaticResource ColorForegroundWhite}"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid Name="Panel" Background="Transparent" SnapsToDevicePixels="True">
                        <Border x:Name="hover" Opacity="0">
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop Offset="0" Color="{StaticResource HighlightComboBoxItem1}"/>
                                    <GradientStop Offset="1" Color="{StaticResource HighlightComboBoxItem2}"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                        <Path Name="Check" SnapsToDevicePixels="False"  Margin="7,5" Width="10" Height="10" HorizontalAlignment="Left"
                              StrokeStartLineCap="Triangle" StrokeEndLineCap="Triangle" StrokeThickness="2" 
                              Stroke="{StaticResource ControlForegroundWhite}" />
                        <ContentPresenter x:Name="content" ContentSource="Header" Margin="24,5,50,5"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="JournalEntryUnifiedViewConverter.JournalEntryPosition" Value="Current">
                            <Setter TargetName="Check" Property="Data" Value="M 0,5 L 2.5,8 L 7,3 "/>
                        </Trigger>
                        <Trigger Property="IsHighlighted" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}"/>
                            </Trigger.ExitActions>
                            <Setter Property="Stroke" TargetName="Check" Value="{StaticResource ControlForeground}"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="MenuItem.IsHighlighted" Value="True"/>
                                <Condition Property="JournalEntryUnifiedViewConverter.JournalEntryPosition" Value="Forward"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Check" Property="Data" Value="M 3 1 L 7 5 L 3 9 z"/>
                            <Setter TargetName="Check" Property="Fill" Value="{StaticResource ControlForeground}"/>
                            <Setter TargetName="Check" Property="Stroke" Value="{x:Null}"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="MenuItem.IsHighlighted" Value="True"/>
                                <Condition Property="JournalEntryUnifiedViewConverter.JournalEntryPosition" Value="Back"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Check" Property="Data" Value="M 7 1 L 3 5 L 7 9 z"/>
                            <Setter TargetName="Check" Property="Fill" Value="{StaticResource ControlForeground}"/>
                            <Setter TargetName="Check" Property="Stroke" Value="{x:Null}"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <JournalEntryUnifiedViewConverter x:Key="JournalEntryUnifiedViewConverterNavigationWindow"/>

    <Style TargetType="{x:Type NavigationWindow}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type NavigationWindow}">
                    <Border Background="Transparent" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="2">
                        <DockPanel>
                            <Grid x:Name="grid" DockPanel.Dock="Top" Height="28" Background="{StaticResource ControlBackgroundNormal}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="16"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Menu Name="NavMenu" Grid.Column="2" Height="16" Margin="1,0,0,0" VerticalAlignment="Center" 
                                      Style="{StaticResource FrameMenu}">
                                    <MenuItem Style="{StaticResource FrameHeaderMenuItem}" ItemContainerStyle="{StaticResource FrameSubmenuItem}"
                                              IsSubmenuOpen="{Binding Path=(MenuItem.IsSubmenuOpen),Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}">
                                        <MenuItem.ItemsSource>
                                            <MultiBinding Converter="{StaticResource JournalEntryUnifiedViewConverterNavigationWindow}">
                                                <MultiBinding.Bindings>
                                                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="BackStack" />
                                                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ForwardStack" />
                                                </MultiBinding.Bindings>
                                            </MultiBinding>
                                        </MenuItem.ItemsSource>
                                    </MenuItem>
                                </Menu>
                                <Button Style="{StaticResource FrameButtonStyle}" Command="NavigationCommands.BrowseBack" Margin="2,0,0,0" Grid.Column="0"/>
                                <Button Style="{StaticResource FrameButtonStyle}" Command="NavigationCommands.BrowseForward" Margin="2,0,0,0" Grid.Column="1"/>
                            </Grid>
                            <Grid>
                                <Border Background="{TemplateBinding Background}"/>
                                <AdornerDecorator>
                                    <ContentPresenter Name="PART_NavWinCP" ClipToBounds="True"/>
                                </AdornerDecorator>
                                <ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="Collapsed" 
                                            IsTabStop="False"/>
                            </Grid>
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="CanGoForward" Value="False"/>
                                <Condition Property="CanGoBack" Value="False"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="NavMenu" Property="IsEnabled" Value="False"/>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value=".7"/>
                            <Setter Property="Background" TargetName="grid" Value="{StaticResource DisabledBrush}"/>
                        </Trigger>
                        <Trigger Property="ResizeMode" Value="CanResizeWithGrip">
                            <Setter TargetName="WindowResizeGrip" Property="Visibility" Value="Visible"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    
    <!-- Дополнительные стили -->

    <!-- ToggleButton - нестандартный стиль -->
    <Style x:Key="ToggleButton_Occupado" TargetType="{x:Type ToggleButton}">
        <Setter Property="Background" Value="#FF1F3B53"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Padding" Value="3"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{StaticResource ToggleButtonBorderBrush_forOccupado}"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusLine_Occupado}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver"/>
                                <VisualState x:Name="Pressed"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetProperty="(FrameworkElement.Opacity)" To=".4" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CheckStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.2"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Checked">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0:0:0.2" To="-180.709" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)" Storyboard.TargetName="path"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unchecked"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused"/>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" 
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" 
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed"/>
                        <Ellipse StrokeThickness="3" Stroke="{TemplateBinding BorderBrush}"/>
                        <Path Data="M0.5,0.5 L68.5,0.5 C68.5,19.277683 53.277683,34.5 34.5,34.5 C15.722319,34.5 0.49999958,19.277683 0.5,0.5 z" Margin="3,3,3,37" Stretch="Fill" 
                              UseLayoutRounding="False" RenderTransformOrigin="0.5,0.5" Cursor="Hand" Fill="{StaticResource ToggleButtonBackgroundON_forOccupado}"
                              Stroke="{StaticResource ToggleButtonBorderBrushON_forOccupado}">
                            <Path.RenderTransform>
                                <ScaleTransform ScaleY="-1"/>
                            </Path.RenderTransform>
                        </Path>
                        <Path Data="M0.5,0.5 L68.5,0.5 C68.5,19.277683 53.277683,34.5 34.5,34.5 C15.722319,34.5 0.49999958,19.277683 0.5,0.5 z" Margin="3,37,3,3" Stretch="Fill" 
                              UseLayoutRounding="False" Cursor="Hand" Fill="{StaticResource ToggleButtonBackgroundOFF_forOccupado}" 
                              Stroke="{StaticResource ToggleButtonBorderBrushOFF_forOccupado}"/>
                        <TextBlock Height="21" Margin="0,8,0,0" TextWrapping="Wrap" Text="{StaticResource ToggleButtonGO}" VerticalAlignment="Top" FontWeight="Bold" HorizontalAlignment="Center" Foreground="{TemplateBinding Foreground}" FontSize="18.667" Cursor="Hand"/>
                        <TextBlock Height="17" Margin="0,0,0,16" TextWrapping="Wrap" Text="{StaticResource ToggleButtonSTOP}" VerticalAlignment="Bottom" FontWeight="Bold" FontSize="13.333" HorizontalAlignment="Center" Foreground="{TemplateBinding Foreground}" Cursor="Hand"/>
                        <Path x:Name="path" Data="M0.5,0.5 L68.5,0.5 C68.5,19.277683 53.277683,34.5 34.5,34.5 C15.722319,34.5 0.49999958,19.277683 0.5,0.5 z" Margin="3,37,3,3" 
                              Stretch="Fill" UseLayoutRounding="False" RenderTransformOrigin="0.5,-0.005" Fill="{StaticResource ToggleButtonBackBackground_forOccupado}"
                              Stroke="{StaticResource ToggleButtonBackBorderBrush_forOccupado}">
                            <Path.RenderTransform>
                                <RotateTransform/>
                            </Path.RenderTransform>
                        </Path>
                        <Ellipse Margin="35" Width="5" Height="5">
                            <Ellipse.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFA7A7A7" Offset="0"/>
                                    <GradientStop Color="#FFC2C2C2" Offset="1"/>
                                </LinearGradientBrush>
                            </Ellipse.Fill>
                            <Ellipse.Stroke>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF353535" Offset="1"/>
                                    <GradientStop Color="#FF1B1B1B"/>
                                </LinearGradientBrush>
                            </Ellipse.Stroke>
                        </Ellipse>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ProgressBar с указанием процентов -->
    <Style TargetType="{x:Type ProgressBar}" x:Key="ProgressBarPercent">
        <Setter Property="Foreground" Value="{StaticResource ControlForegroundWhite}"/>
        <Setter Property="Background" Value="{StaticResource ControlLightBackground}"/>
        <Setter Property="Maximum" Value="100"/>
        <Setter Property="Height" Value="20"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ProgressBar}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="IndeterminateProgressBar" RepeatBehavior="Forever">
                            <ObjectAnimationUsingKeyFrames Duration="00:00:00" Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="IndeterminateRoot">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Duration="00:00:00" Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="DeterminateRoot">
                                <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(LinearGradientBrush.Transform).(TransformGroup.Children)[0].X" Storyboard.TargetName="IndeterminateGradientFill">
                                <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:.35" Value="20"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid x:Name="Root">
                        <Border x:Name="PART_Track" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
                        <Grid x:Name="ProgressBarRootGrid">
                            <Grid x:Name="IndeterminateRoot" Visibility="Collapsed">
                                <Rectangle x:Name="IndeterminateSolidFill" Margin="{TemplateBinding BorderThickness}" Opacity="1" RenderTransformOrigin="0.5,0.5" StrokeThickness="0" Fill="{StaticResource BrushTrackProgressBar}"/>
                                <Rectangle x:Name="IndeterminateGradientFill" Margin="{TemplateBinding BorderThickness}" Opacity="0.7" StrokeThickness="1" Fill="{StaticResource IndeterminateBrushProgressbar}"/>
                            </Grid>
                            <Grid x:Name="DeterminateRoot" Margin="1">
                                <Border x:Name="PART_Indicator" Background="{StaticResource BrushTrackProgressBar}" HorizontalAlignment="Left" Margin="-1">
                                    <Rectangle x:Name="GradientFill" Opacity="0.7" Visibility="Collapsed" Fill="{StaticResource IndeterminateBrushProgressbar}"/>
                                </Border>
                            </Grid>
                            <Grid x:Name="GridValue" HorizontalAlignment="Center" VerticalAlignment="Center">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Label Grid.Column="0" Padding="0" Foreground="{TemplateBinding Foreground}" Content="{TemplateBinding Value}" Style="{x:Null}" />
                                <Label Grid.Column="1" Padding="0" Foreground="{TemplateBinding Foreground}" Content="%" Style="{x:Null}" />
                            </Grid>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Orientation" Value="Vertical">
                            <Setter Property="LayoutTransform" TargetName="Root">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsIndeterminate" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource IndeterminateProgressBar}"/>
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value=".6" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>